# Dynamic display of devices

**URL:** <https://community.homey.app/t/dynamic-display-of-devices/121204>\
**Category:** Questions & Help\
**Created:** [November 21, 2024, 5:10pm UTC](https://community.homey.app/t/dynamic-display-of-devices/121204 "2024-11-21T17:10:03Z")\
**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:** [November 21, 2024, 5:35pm UTC](https://community.homey.app/t/dynamic-display-of-devices/121204/2 "2024-11-21T17:35:21Z")

</div>

Read this thread, please:  
[https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/11?u=peter\_kawa](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/11)

Here’s the script I use:

```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: \nName: ${device.name} \nZone: ${device.zone} \n(ZoneName: ${device.zoneName}) \n[device.class: ${device.class} \ndevice.capabilities: ${device.capabilities}]`); 

      if(device.name != ""){
      windowOpen = true;
      if(windowText=="")
      windowText = device.name + "\t(Zone: " + device.zoneName + ")";
      
      else
      windowText = windowText + "\n" + device.name + "\t(Zone: " + device.zoneName + ")";
      }
    }
  }
});

if(windowOpen == true)
windowText = "\nThese windows/doors are still open:\n" + windowText + "\n";
else
// comment this out if you don't want a msg when all's fine:
windowText = "All windows & doors are closed.";

Homey.flow.runFlowCardAction({
        uri: 'homey:manager:notifications',
        id: 'create_notification',
        args: {
          text: String(windowText) + '\n[Peter Away - window/door Open Notif]'
        },
      });

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

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

return (true);

// Initial script by RonnyW.

```

The script is called with a flow like this:

> ![1000037938](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/2/a2c62d33083a21c9a57ec1104a8026b07c608768.jpeg)

Maybe this indicator is useful as well

 ![17322108479021670109338300856999](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/7/d7c0cd8dd91066191305a9fdb24cf8fc46bc2e3f.jpeg)  
 ![17322109138621397938129304538169](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/a/7aba6d3c1657102e8b0ec29037d7feb783dc9801.jpeg)

Check out this post for the flow and howto:

> [@Share Your Device! - Advanced Virtual Devices from Device Capabilities](https://community.homey.app/t/share-your-device-advanced-virtual-devices-from-device-capabilities/68676/88):
>
> Master Doors and Windows status indicator This device + accompanying flow shows the status of 3 door/window sensors. It’s off and shows 0 #Open when all are closed It’s on and shows 1 #Open when 1 is opened It’s on and shows 2 #Open when 2 are opened and so forth Device tile: All contact sensors overview in the device settings: Flow: Apps …

---

_[View the full topic](https://community.homey.app/t/dynamic-display-of-devices/121204)._
