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

I have several aqara sensors around the house and would like to have a flow to be notified that when it rains to get a notification on Google home (audio) and on the phone which states which doors and windows are open.

Any help appreciated! Thanks in advance!

Please don’t get me wrong but you are asking others to do the brainwork for you in advance.

I suggest now that you are able to define your requirements and you know which devices you would like to use, you should develop the basic framework from initial flow ideas and ask specific questions about the problems where you are stuck.

Break the requirement down into individual problems:

which kind of rain detection?
how to accumulate open aqara sensors? → Here I can give you a solution based on homeyscript.
sending them to Google home as an audio announcement
sending them as a phone notification

For each of these problems you will already find a solution in this forum.

Sorry let me try and put more context.

What I’m struggling with is how to report all sensors with “contact alarm on”.

The only way I see it, would be to create several flows. Though that seems like the long way and I wondered if there was an easier way to get the status from all Aqara’s sensors? Right now I have 15 sensors.

I created a HomeyScript for checking open windows.
You could do something like this in a flow started with a rain sensor.
As rain sensor I use a rain sensor board with a aqara window sensor (cables attached at the reed sensor and connected to the rain board.

Here is an example for a script (sorry, only german :wink:)

Have you looked at the group app? That allows you to add multiple devices into one device.

Also you could add all of the rain sensors in to one zone and use the zone is active card

Yeah I checked this app, but what I don’t get is how to report the individual sensors that are on, so I don’t have to check each one individually.

I have;

If group active

And Raining
And schedule is between 9:00 - 23:00

  • I don’t want a Google home announcement after I’m asleep.


If you want to check each window sensor individual, you will need a flow for each sensor.
You yould use HomeScript to do the checks and build a text with each window and then make a TTS output. That needs some JavaScript codings, but the script (linked in my answer above) is easy to unterstand. This script can be used in a flow condition (AND part) and the text is returned an flow tag for use in THEN part.


Nice script @RonnyW
But idk if @jpcams is ready for that at this point?

JP, a quite simple approach can be something like this. It only requires adding all of your sensors to the alert message, but it works. Maybe this gets you going to more advanced flows (and scripts)

and for TTS during daytime:

1 Like

I finally sat down and looked at your script. Thanks a lot! At first I was a bit resistant to the idea as I thought since I’m not a dev, I would spend an obscene amount of time trying to decipher your hieroglyphics! :slight_smile: Glad I was wrong and thanks again for sharing this script.

I will share my version of your script below in case it helps anyone else who is looking for a similar solution:

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 = "";
if( == "Living room sliding door")
currentText = "Living Room";
if( == "Kitchen Window Sensor")
currentText = "Kitchen";
if( == "Office Window Sensor")
currentText = "Office";
if( == "Kid1 Window Sensor")
currentText = "Kid1 room";
if( == "Kid2 Window Sensor")
currentText = "Kid2 room";
if( == "Bedroom Window Sensor")
currentText = "Bedroom";
if( == "Tall bedroom Window Sensor")
currentText = "Tall bedroom window";
if(currentText != ""){
windowOpen = true;
windowText = currentText;
windowText = windowText + ", " + currentText;
if(windowOpen == true)
windowText = "Window open: " + windowText;
windowText = "All good";
await tag("windowText", windowText );
return windowOpen;

It’s great. How do I simply save the result of the script in a variable so I can send myself a notification?

The variables are created and filled by the script already.
First, make sure to run the script minimal 1 time in HomeyScript editor, so the variables are getting created and become available and findable from the flow editor.
You can simply run the script from a AND card (go to Homeyscript in the list, and then select the script), and as action, create a notification card and select the variable [windowText], which is grouped under “Homeyscript”.

Screenshot of the action card while the “share a flow” doesn’t display the variable:

Result pushmessage (it reports an open door and window):

Thanks a lot! I didn’t know exactly how it worked. Now I’m happy :slight_smile:

1 Like