Start above and send message if below

Hi Guys,

I want to have a flow which tells via Alexa-Routine that the room humidty in bathroom drops below 50% (to remember me to close the window after daily showering) but only if it was higher before.

To be honest I've no clue how to manage that at the moment. Do you have some hints for me which leads me in the right direction?

Thx in advance for any input!

Cheers
Florian

Welcome to the forum Florian.
One way to achieve that is to use a function node and in there save the previous value of humidity and then you can compare the current value with the previous value to determine whether to send on a message to trigger Alexa. Have a look in the docs at that section on Writing Functions and in there it will tell you how to use the node context to save the previous value.

This would be a simple task if you had a smart home controller. and a window temp and humidity sensors

Hey Guys,

first - thx for your help. Unfortunately I do not "speak" java-script so I'm not really able to program this via a function node.

Of course I'm using a smart-home-controller (namely: HomeAssistant) - unfortunately I do not have Window-Sensors (of course would be simple with this)

Cheers

Why not buy a cheap sensor, i'm sure the aqara zigbee devices work with home assistant. You can pick these sensors up for £10. Or fit a humidity fan and not have to open widow, as fan will start when humidity rises, uk cost £30 plus fitting

Hey, yes I know - I'm already using Aquara Devices (for humidity ;)) ... It's because I wanted to know if it's possible to do it that way I try to manage currently.

Cheers

Yes it's possible.

Do you know how? :wink:

As Colin said you will need to store the last value and use a function node or possibly switch node to compare values.

As I said before - I do not "speak" java-script so I'm not really able to program this via a function node. Maybe some can give me a "template".

thx!

you could use some change nodes, switch nodes and flow variables

show us what you have tried and i am sure this forum will push you in the right direction.

Hey, this was my first try - but of course it always triggers if value changes

[{"id":"7bf9c73d.cc7968","type":"server-state-changed","z":"b701708f.d6fa2","name":"Badezimmer Luftfeuchtigkeit <50%","server":"cdcde6c6.b307a8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.xiaomi_mija_temperature_01_humidity","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"50","halt_if_type":"num","halt_if_compare":"lt","outputs":2,"output_only_on_state_change":true,"x":180,"y":60,"wires":[["eee2552d.1736b8"],[]]},{"id":"3f04b7b9.f48ae8","type":"delay","z":"b701708f.d6fa2","name":"","pauseType":"delay","timeout":"7","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":540,"y":60,"wires":[["9d0117db.751c38"]]},{"id":"eee2552d.1736b8","type":"rbe","z":"b701708f.d6fa2","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":410,"y":60,"wires":[["3f04b7b9.f48ae8"]]},{"id":"9d0117db.751c38","type":"alexa-remote-routine","z":"b701708f.d6fa2","name":"","account":"67422e97.c87f7","routineNode":{"type":"speakAtVolume","payload":{"type":"regular","text":{"type":"str","value":"Die Luftfeuchtigkeit im Badezimmer ist wieder unter 50%. Das Fenster kann wieder geschlossen werden."},"volume":{"type":"num","value":"100"},"mode":"set","devices":["G090XG079414118F"]}},"x":750,"y":60,"wires":[[]]},{"id":"cdcde6c6.b307a8","type":"server","z":"","name":"HA (MULATZ)","legacy":false,"hassio":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"67422e97.c87f7","type":"alexa-remote-account","z":"","name":"Alexa-Account","authMethod":"proxy","proxyOwnIp":"192.168.100.208","proxyPort":"3456","cookieFile":"/root/.node-red/alexa-remote/auth.txt","refreshInterval":"3","alexaServiceHost":"layla.amazon.de","amazonPage":"amazon.de","acceptLanguage":"de-DE","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

Add a fow - with an inject - to a change node to put the starting humidity into a flow variable maybe called startingHumidity.

Instead of using the server-state node during testing, just use three inject nodes with different numbers connected to a change node that moves the value into a flow variable - maybe call it newHumidity. Next use a switch node to compare the two values. if the condition arises where you want to do something, place a change node to move the new Humidity to the startingHumidity and output a message to a debug node.

Once you have this working, output your message to the Alexa-Routine to see if that works

next add the sensor or whatever is getting the humidity to the start to see if it works.

Once it is working you can remove the three inject nodes used for testing.

I'm afraid you got me wrong. I don't want to trigger if the value arise above a value but if it falls down below AGAIN after it was above before. I do not see this in your example to be honest.

Thx

when I said 'arise' I mean when the condition occurs. You define the condition. It might help you (me) it you were to write out the steps you see involved - create some psuedo code then set that as a guide to building your flow.

Sorry for misunderstanding - english is not my native language. In this case - I don't get it. How should your example trigger after it falls below again. Sorry when I act stupid.

BR

So you want to be reminded if the humidity goes below 50% after rising for a short period of time. First you should decide on what that time interval is...10 minutes, 30 minutes?

Lets say 15 minutes.

pseudo code - flow 1
1 - store current time in start time (ST) and current time (CT)
2 - read humidity and store it in highest humidity (HH)
3 - humidity dropping (HD) to 'NO'

pseudo code - flow 2
1 - read humidity
2 - if current humidity (CH) > highest humidity (HH), replace HH with CH
3 - if current humidity (CH) < highest humidity (HH), set humidity dropping to 'YES'
4 - read time
5 - if current time - start time (CT - ST) < 15 do nothing else if HD = YES AND current humidity < 50 shut the window

You realize you have a lot of edge cases to think about.

What if it is cold outside and the humidity is 30% will you still open the window to take the shower?
What if it is hot outside and you have air conditioning on inside, will you still open the window?
What if it is nice outside and you want to leave the window open even after taking the shower?
Should you have a switch on the window to activate the flow - i.e. don't run it if the window is closed?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.