Automation trigger on rising humidity for a humidity device which only sends few updates

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

  1. I added a statistics helper device which calculates the average humidity of the bathroom the last hour
  2. 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” }}
  3. 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?

Many use the derivative sensor to calculte how fast the humidify rises or falls. It uses past values, so it comes pretty close to what you used to do. You start ventilation when the derivative indicates a steep rise.

tx, i’ll try this solution.

i also manufactured a workaround myself to force the statistics sensor to keep calculating with the most recent values if no measurements sent by fooling Home Assistant there are new values every minute

The trick was to create a helper sensor of type template, which uses the following template

{% if as_timestamp(now())>0 %}
{{ states(“sensor.badkamer_boven_humptemp_badkamer_boven_humptemp_humidity_air”) | float + 0.05 - (range(0,10) | random / 100) }}
{% endif %}

The condition is now always true (as_timestamp(now()) will always be greather than zero), so every minute it generates a new reading. The ways every minute a “measurement” is captured and eliminates my original issue.

A deravative sensor seems a more clean solution, so i will check that one also