# Report any open doors/windows

**URL:** <https://community.homey.app/t/report-any-open-doors-windows/77972>\
**Category:** Flows\
**Tags:** flow\
**Created:** [March 18, 2023, 11:56am UTC](https://community.homey.app/t/report-any-open-doors-windows/77972 "2023-03-18T11:56:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 18, 2023, 4:36pm UTC](https://community.homey.app/t/report-any-open-doors-windows/77972/2 "2023-03-18T16:36:24Z")

</div>

Hi Marcel,

I use this Homeyscript script for that. It sends a timeline report, so you just have to call this script in a flow:  
(I use the same script for rain/snow/storm alerts)

```auto
// Check if certain doors or windows is open?

let devices = await Homey.devices.getDevices();
let windowText = "";
let currentText = "";
let logText = "";
let windowOpen = false;
_.some(devices, device => 
{
if ( device.class == 'sensor' ) 
// device.class is found at https://tools.developer.homey.app/tools/devices
  {
  if( device.capabilitiesObj &&
  device.capabilitiesObj.alarm_contact &&
  device.capabilitiesObj.alarm_contact.value )
    {
    currentText = "";
    // to compare and see if there is no typing error
    console.log(`- Open door/window script check: ${device.name} (Zone: ${device.zoneName}), [device.class: ${device.class}, device.capabilities: ${device.capabilities}]`); 
    
      if(device.name != ""){
      windowOpen = true;
      if(windowText=="")
      //windowText = device.name + "\t(" + device.zoneName + ")";
      windowText = device.name + "\t(" + device.zoneName + ")";
      
      else
      windowText = windowText + "\n" + device.name + "\t(" + device.zoneName + ")";
      }
    }
  }
});

if(windowOpen == true)
windowText = "\nDe volgende ramen of deuren staan nog open:\n" + windowText + "\n";
else
// comment this out if you don't want a msg when all's fine:
windowText = "Alle deuren en ramen zijn dicht";

Homey.flow.runFlowCardAction({
        uri: 'homey:manager:notifications',
        id: 'create_notification',
        args: {
          text: windowText
        },
      });

//just to check
console.log("\nOutput:\n", windowText);

// Create / update HomeyScript variabele
await tag("door_windowText", windowText);

return (true);

// Initial script by RonnyW.

```

( Credits to @RonnyW !)

- Flow:  

- Paste the script in the Homeyscript THEN card “Run code”

---

_[View the full topic](https://community.homey.app/t/report-any-open-doors-windows/77972)._
