Different reaction when moving a condition from trigger-part of an automation to condition-part

We have in mostly all our rooms Xiaomi Temperature, Humidity (and sometimes Pressure) Sensors.
To prevent mold and get systemtically the humidity which comes out off the walls of the new building we live in, I thought it would be a good idea to send jabber notifications every 5 % the humidity increases and I started with bigger than 55%. Every 5 % the humidity climbs up I get a notification via jabber to be remembered to open the windows to exchange the air.

Example Humidity climbs through the day from 48% up to 72% I get messages a little larger than 55%, 60%, 65% and 70%. Here the code for our guest room which works very well:

- alias: Hinweis rLF Anstieg GZ 5er Schritte
  trigger:
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d000247cfd4.state | float ) > 55 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d000247cfd4.state | float ) > 60 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d000247cfd4.state | float ) > 65 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d000247cfd4.state | float ) > 70 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d000247cfd4.state | float ) > 75 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d000247cfd4.state | float ) > 80 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d000247cfd4.state | float ) > 85 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d000247cfd4.state | float ) > 90 }}"
  action:
    - service: notify.hassjabber
      data:
        message: |
          ***
          HINT rLF {{ states.sensor.humidity_158d000247cfd4.state }} % in GZ
          Do OPEN the window
          
          rLF {{ states.sensor.humidity_158d000247cfd4.state }} %   Temp {{ states.sensor.temperature_158d000247cfd4.state }} °C   LDruck {{ states.sensor.pressure_158d000247cfd4.state }} hPa
          ***

If you open the window and humidity sinks down to 56% and starts increase again larger than 60% is the next point when I get the jabber notification.

Now we have also bought us some Xiaomi Door-Window-Sensors and I thought it must be easy only to send the jabber notification when it is necessary to send the message and that is when the window is closed. So I thought moving the trigger to the condition and only setup the “closed” Window as trigger and combine it with AND to the different humidity limits and combine these humidity levels with OR here the part of our bathroom:

- alias: Hinweis rLF Anstieg Bad 5er Schritte
  trigger:
    - platform: template
      value_template: "{{ ( states.binary_sensor.door_window_sensor_158d00024e5420.state ) == 'off' }}" #		on = auf | off = zu
  condition:
    condition: and
    conditions:
      condition: or
      conditions:
        - condition: template
          value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 55 }}"
        - condition: template
          value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 60 }}"
        - condition: template
          value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 65 }}"
        - condition: template
          value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 70 }}"
        - condition: template
          value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 75 }}"
        - condition: template
          value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 80 }}"
        - condition: template
          value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 85 }}"
        - condition: template
          value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 90 }}"
  action:
    - service: notify.hassjabber
      data:
        message: |
          ***
          Hint rLF {{ states.sensor.humidity_158d00020edc9e.state }} % im Bad
          Do OPEN the window
          
          rLF {{ states.sensor.humidity_158d00020edc9e.state }} %   Temp {{ states.sensor.temperature_158d00020edc9e.state }} °C
          ***

Looking at the second part I see I do only once get a humidity notification via jabber even if the humidity increases from 54% up to 82% when it is really necessary to open the window and let fresh and dry air in.

Probably there must only be a really little change in the conditions because I made thinking errors by joining the conditions. Could somebody help me to clarify the problem?

In the higher humidities the risk of mold is bigger so it would be nice if the notifications work at that point really steady.
Alternatively to prevent the rooms in winter when it is outside really cold from cooling down to much which sets up the costs for heating unnecessarily. I added automations which warn me if the window is open and the temperature sinks below 19°C smooth and forceful below 16°C, this also does not work properly besides the problem I have to solve is equally.

Many thanks for your help and leading me to the right path again.

It will only “trigger” when the window closes i.e. goes from the state of open/on to closed/off, since triggers only work when they change state. So how you have it, it won’t trigger till the window has opened then closed. I would use the trigger as the humidity changing and add the condition that the window has to be closed.

Many thanks!

I changed for the toilet this is the room where over night the humidity increases mostly from about 52% to about 62%.
See if it will work but your explanation sounds logical.

Hey keithhh666 thanks, it works!


Here now the changes I made so that all who want to see the solution can see it directly:

- alias: Hinweis rLF Anstieg Bad 5er Schritte
  trigger:
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 55 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 60 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 65 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 70 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 75 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 80 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 85 }}"
    - platform: template
      value_template: "{{ ( states.sensor.humidity_158d00020edc9e.state | float ) > 90 }}"
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: "{{ ( states.binary_sensor.door_window_sensor_158d00024e5420.state ) == 'off' }}" #		on = auf | off = zu
  action:
    - service: notify.hassjabber
      data:
        message: |
          ***
          Hint rLF {{ states.sensor.humidity_158d00020edc9e.state }} % im Bad
          Do OPEN the window
          
          rLF {{ states.sensor.humidity_158d00020edc9e.state }} %   Temp {{ states.sensor.temperature_158d00020edc9e.state }} °C
          ***
1 Like