Hi,
I am converting my domoticz system to a home assistant setup, but have difficulty converting my automation in which the ventilation is automatically switched on when the humidity rises in my 2 bathroom… (which indicates someone is showering or taking a bath)
The business rule i implemented in domoticz (and worked flawlessly) is quite simple: If the current humidity 5% or more higher than the average of the last hour, than make sure the ventilation runs for at least another hour.
In domoticz this is a dzVents script which gather data every minute, and also every minute does this check.
In home assistant i have no dzvents, so with the help of this forum i came up with the following solution
- I added a statistics helper device which calculates the average humidity of the bathroom the last hour
- I added a template helper device (type binary sensor, active/inactive) which checks the following template: {{ states.sensor.badkamer_humtemp_badkamer_humtemp_humidity_air.state | float > states.sensor.badkamer_gemiddelde_vochtigheid_laatste_uur.state | float + 5 and states.sensor.badkamer_gemiddelde_vochtigheid_laatste_uur.state != “unkown” }}
- I added an automation which uses the template sensor as trigger to stop and start the ventilation
Unfortunately it works only about 50% of the time. It occurs quite often that although humidity rises, the template sensor does not give a positive and hence the automation is not triggered.
I analyzed and found the cause: My (z-wave) humidity sensor only does updates when there are significant changes in the humidity (e.g. >5% diff or something like that, otherwise it remains in sleep mode).
So the behaviour is:
- for a long (read: More that 60 mins) time both sensors (humidity + average humidity) have the same low value, cause there are no significant changes in humidity
- Then someone starts showering, so humidity increases a lot, so the humidity sensor gives a very high new reading, mostly in the 97/98%, it is very close to the shower.
- But since there are no other readings in the hour before that, also the “average humidity of the last hour” sensor also then immediately jumps to the same 97/98%
- After that the humidity sensor goes up more to (up to 100%), but the difference is never >5%, so the template device is not triggered
So long story short: My question is: I want to start an automation based on that high difference from that low value to that high value. But it shoud be as generic, that this can happen in a few sensor updates… HOw do i do that?