# Notification highlighting specific device using logic

**URL:** <https://community.homey.app/t/notification-highlighting-specific-device-using-logic/114752>\
**Category:** Questions & Help\
**Created:** [August 21, 2024, 11:17am UTC](https://community.homey.app/t/notification-highlighting-specific-device-using-logic/114752 "2024-08-21T11:17:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaaBo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/haabo/32/90358_2.png) [@HaaBo](https://community.homey.app/u/HaaBo)\
**Post date:** [August 21, 2024, 11:17am UTC](https://community.homey.app/t/notification-highlighting-specific-device-using-logic/114752/1 "2024-08-21T11:17:31Z")

</div>

Hi!

I have an idea I want to execute in a flow, but cant seem to wrap my head around solving this one:

In my apartment i have several windows, all outfitted with contact sensors. I have made a flow that tells me via a push notification if any of these windows are open when I leave home. So far so good. What I CANT figure out though, is if there is any way to use logic in Homey to tell me which one of the contact sensors are triggering, straight in the push-notification?

Any takers?

Cheers,  
Haakon

---

<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:** [August 21, 2024, 11:14pm UTC](https://community.homey.app/t/notification-highlighting-specific-device-using-logic/114752/2 "2024-08-21T23:14:49Z")

</div>

I did it with a script, which can be started with the condition “Not all contact alarms are turned off”  
Flow:

 ![Screenshot from 2024-08-22 01-03-10](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/d/7db42b0551313826dd0a4d32b644f589bb430f9f.png)

The push messages can send these kind of texts, mentioning the open windows or doors:

> ![Screenshot from 2024-08-22 01-07-46](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/e/cee5ed80b73ea75a8ec84415e96e56cc9e2190c5.png)

When all is closed (might be handy when testing):

> ![Screenshot from 2024-08-22 01-07-59](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/6/f646b1ff8ba90671544c3048fe09b7317e55aab9.png)

The script, called “deur\_raam-nog\_open”

```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: windowText + '\n[Peter Away - window/door Open Notif]'
        },
      });

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

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

return (true);

// Initial script by RonnyW.

```

---

<div class="post-metadata">

**Author:** ![HaaBo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/haabo/32/90358_2.png) [@HaaBo](https://community.homey.app/u/HaaBo)\
**Post date:** [August 22, 2024, 7:25pm UTC](https://community.homey.app/t/notification-highlighting-specific-device-using-logic/114752/3 "2024-08-22T19:25:11Z")

</div>

Wow, this is way beyond my skillset in Homey @Peter_Kawa , thank you for taking the time for such an elaborate post!!
