Homey Community Forum

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.

Then…

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.

2 Likes

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