# Help with a flow: When raining, notify which doors/windows are open

**URL:** <https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331>\
**Category:** Questions & Help\
**Tags:** flow\
**Created:** [June 11, 2021, 6:57pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331 "2021-06-11T18:57:47Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [June 7, 2022, 11:47am UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/21 "2022-06-07T11:47:35Z")

</div>

That looks all ok. You can try to make some printouts with console.log(). Perhaps the “device” object inside the loop. Check the .name attribute. Not that there is an additional space somewhere.

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [June 7, 2022, 11:57am UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/22 "2022-06-07T11:57:35Z")

</div>

Did a test with my two sensors and the script works perfect.

---

<div class="post-metadata">

**Author:** ![timvdhoorn](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/timvdhoorn/32/55746_2.png) [@timvdhoorn](https://community.homey.app/u/timvdhoorn)\
**Post date:** [June 7, 2022, 12:00pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/23 "2022-06-07T12:00:06Z")

</div>

That is the strange part. The device name is exactly the same. I also tried with console.log to display the text but it will always respond with false. Very strange…

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [June 7, 2022, 12:10pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/24 "2022-06-07T12:10:14Z")

</div>

> [@timvdhoorn](#):
>
> ` if(currentText != ""){`

Is the script processing the part inside the line above?  
Can you print the windowText and check what’s filled in?

---

<div class="post-metadata">

**Author:** ![timvdhoorn](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/timvdhoorn/32/55746_2.png) [@timvdhoorn](https://community.homey.app/u/timvdhoorn)\
**Post date:** [June 7, 2022, 12:16pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/25 "2022-06-07T12:16:58Z")

</div>

Hi RonnyW, you mean like this?

 ![Screenshot 2022-06-07 at 14.16.23](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/1/31542c623612b3606a8b59e3711e53ae3c6121c1.png)  
output is none

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [June 7, 2022, 12:31pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/26 "2022-06-07T12:31:48Z")

</div>

Just after the IF brackets { }. At the current place the variable is not alreasy set.

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [June 7, 2022, 12:34pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/27 "2022-06-07T12:34:59Z")

</div>

Try a Homey reset, script is tested ok (sorry for interfering)

---

<div class="post-metadata">

**Author:** ![timvdhoorn](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/timvdhoorn/32/55746_2.png) [@timvdhoorn](https://community.homey.app/u/timvdhoorn)\
**Post date:** [June 7, 2022, 3:08pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/28 "2022-06-07T15:08:56Z")

</div>

I already tried that. A PTP reset. but that didn’t work…

---

<div class="post-metadata">

**Author:** ![timvdhoorn](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/timvdhoorn/32/55746_2.png) [@timvdhoorn](https://community.homey.app/u/timvdhoorn)\
**Post date:** [June 7, 2022, 3:10pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/29 "2022-06-07T15:10:02Z")

</div>

![Screenshot 2022-06-07 at 17.09.33](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/7/a7b651876970479adbd3f1c77aa2331639682ac8.jpeg)

still says that the windows are closed

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [June 7, 2022, 3:36pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/30 "2022-06-07T15:36:38Z")

</div>

Why not putting many console.log lines in your code, so you can see the different values at many places. ( I did this for device.name, you can use the result for copy-past )  
Run this code by the Test command and you see directly if the values are as expected.

```auto
 // Vul hier al je contact sensors in, device.name == "Exacte sensornaam"
   // currentText = "Sensornaam"
   console.log("--Device--", device.name ); // to compare and see if there is no typing error
   if( device.name == "Deur Terras-Wnk")
   currentText = "Woonkamer Terras deur";

```

---

<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:** [June 7, 2022, 4:06pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/31 "2022-06-07T16:06:42Z")

</div>

Maybe try a diff on this script and yours?  
This works OK

```auto
// Deur of raam nog open?

let devices = await Homey.devices.getDevices();
let windowText = "";
let currentText = "";
let logText = "";
let windowOpen = false;

_.some(devices, device => 
{

if(device.class == 'sensor')
{
if( device.capabilitiesObj &&
device.capabilitiesObj.alarm_contact &&
device.capabilitiesObj.alarm_contact.value )

{
currentText = "";

// Vul hier al je contact sensors in, device.name == "Exacte sensornaam"
// currenText = "Sensornaam"

console.log("--Device--", device.name ); // to compare and see if there is no typing error

if( device.name == "Deur Trap")
currentText = "Trap";

//if( device.name == "Deur Badkamer")
//currentText = "Badkamer";

if( device.name == "Raam Slaapkamer")
currentText = "Slaapkamerraam";

if( device.name == "Deur Koelkast")
currentText = "Koelkast";

if(currentText != ""){
windowOpen = true;

if(windowText=="")
windowText = currentText;

else
windowText = windowText + ", " + currentText;
}
}
}
});

if(windowOpen == true)
windowText = "De volgende deuren of ramen staan nog open: " + windowText;
else
windowText = "Alle deuren en ramen zijn dicht";

console.log(windowText);

// Creëer / update HomeyScript variabele
await tag("door_windowText", windowText);

return windowOpen;

```

> ![Screenshot_20220607-182753_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/b/0b76afd2180fcbff4d4749e861ba4c9503bac463.jpeg)

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [June 7, 2022, 4:17pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/32 "2022-06-07T16:17:32Z")

</div>

> [@Peter\_Kawa](#):
>
> `return windowText;`

he needs a boolean for the Flow! The text is already in the Tag.

---

<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:** [June 7, 2022, 4:21pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/33 "2022-06-07T16:21:47Z")

</div>

I know, but the problem isn’t in that part of the code when testing the script in the console.  
I’ve adjusted it.

---

<div class="post-metadata">

**Author:** ![timvdhoorn](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/timvdhoorn/32/55746_2.png) [@timvdhoorn](https://community.homey.app/u/timvdhoorn)\
**Post date:** [June 7, 2022, 4:46pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/34 "2022-06-07T16:46:08Z")

</div>

Hi Peter,  
This script also doens’t work for me, very strange…

 ![Screenshot 2022-06-07 at 18.44.52@2x](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/d/ed2749d127bd019dae6e3bb2d5bb7dd6776cfbc0.png)

---

<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:** [June 7, 2022, 4:53pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/35 "2022-06-07T16:53:07Z")

</div>

Has “Balkondeur-ka” an inverse option?  
Or, what happens if you close that door and then test the script?

---

<div class="post-metadata">

**Author:** ![timvdhoorn](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/timvdhoorn/32/55746_2.png) [@timvdhoorn](https://community.homey.app/u/timvdhoorn)\
**Post date:** [June 7, 2022, 4:56pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/36 "2022-06-07T16:56:53Z")

</div>

When I close the door, the script also returns false. Invert sensor also doens’t change a thing.  
I also tried reinstalling the Homeyscript app but still the same… ☹

PS. I also tried changing the name of the sensor but this also gives the same result…

---

<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:** [June 7, 2022, 5:10pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/37 "2022-06-07T17:10:23Z")

</div>

Auch. That is odd.

What happens if you temporary replace the condition “not all contacts are off” with “Balkondeur-ke contact is on”

 ![Screenshot_20220607-190706_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/a/ca6b0990ce585c9f4dba1a36a20bac1cb09fd752.jpeg)

Or / else:  
What happens if you create a virtual door contact, set it to alarm=true, and add it to the script’s sensor section?

And is “Thuis” the top level of your zones?

What happens if you create this flow and open up the Balkondeur-ke door?

It should be reported.

> ![Screenshot_20220607-191654_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/9/693a3746f4165d3c43fd99ab2cd8642487013684.jpeg)

---

<div class="post-metadata">

**Author:** ![timvdhoorn](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/timvdhoorn/32/55746_2.png) [@timvdhoorn](https://community.homey.app/u/timvdhoorn)\
**Post date:** [June 7, 2022, 7:38pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/38 "2022-06-07T19:38:27Z")

</div>

I will try tomorrow, thanks!

Could it maybe go wrong because I’ on the 7.4.1 firmware?; which firmware are you running?

---

<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:** [June 7, 2022, 8:02pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/39 "2022-06-07T20:02:51Z")

</div>

YW.  
I’ve updated to 7.4.1 just a the other day, so in theory it can’t really be an issue 🙃

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [June 7, 2022, 11:49pm UTC](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/40 "2022-06-07T23:49:24Z")

</div>

Can you try to run the script ( with the extra console.log ) when all your door/window sensors are activated, the console.log should show them as  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/1/619af633589e89c71b714b6449eff753d2024a00.png)

so you can see if the problem is with all the sensors or just this one you are testing now.

For me, Version 7.4.1. is running since 12-05 without problems.

[Previous page](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331.md?page=1)

[Next page](https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331.md?page=3)
