When does a trigger thats 'below' a certain level actually fire

I have a script that turns off a fan when the humidity drops below (say) 75.

My question is this.

Does the trigger only fire when the humidity crosses that threshold, (say it goes from 77 to 74), or would any change thats below 75 also trigger it, such as 68 to 65.

My initial testing would suggest it only fires when it crosses the threshold.

Only when it crosses the threshold.

Reference: Numeric State Trigger

1 Like

Ok, so could I do this ?:-

trigger:
  - type: humidity
    platform: device
    device_id: 457ad6a2ee920963e324bab25c4242db
    entity_id: sensor.lumi_lumi_weather_humidity_3
    domain: sensor
    below: 75
    above: 1

Actually, I assume thats not going to work, all I’ve done is create two thresholds.

That is able to trigger twice:

At the moment when the sensor’s value:

  1. Decreases below 75
  2. Increases above 1

So the only triggering is when the value crosses either threshold.

Not sure what you’re trying to do?

Are you wanting it to trigger on every humidity state change when humidity is below 75?

If so, you could use a normal entity state trigger with a numeric state condition.

Ah ok, so rather than having the threshold set in the trigger, do this ?:-

trigger:
  - type: humidity
    platform: device
    device_id: 457ad6a2ee920963e324bab25c4242db
    entity_id: sensor.lumi_lumi_weather_humidity_3
    domain: sensor
condition:
  - condition: numeric_state
    entity_id: sensor.lumi_lumi_weather_humidity_3
    below: 75

Ok seems I can’t do the above because I get the warning:-

Message malformed: must contain at least one of below, above.’ (in the trigger)

I’d gone down the road of using a template sensor to give me a boolean true or false using:-

{{ (states(‘sensor.lumi_lumi_weather_humidity_3’)) | int > 75 }}

That will trigger whenever the sensor’s value is below 75.

What’s the intended application for triggering on any value below 75?

I have an automation that turns on a fan when humidity reaches a certain threshold, it then keeps it on for 10 minutes, then 10 minutes later it turns if off.

But it should only turn the fan off if the humidity at that point (10 minutes later), is 75 or below.

Sometimes, at the 10 minute mark, the humidity has already dropped below the threshold, so the fan stays on. I want it to check any humidity change to see if thats 75 or below.

Post the automation.

This is the automation that turns on and off the fan:-

mode: restart
trigger:
  - type: humidity
    platform: device
    device_id: 457ad6a2ee920963e324bab25c4242db
    entity_id: sensor.lumi_lumi_weather_humidity_3
    domain: sensor
    above: 75
action:
  - type: turn_on
    device_id: 7d74b7c8e812e444474b8c4f46021cde
    entity_id: switch.aqara_switch_module_ensuite_switch
    domain: switch
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  - choose:
      - conditions:
          - type: is_humidity
            condition: device
            device_id: 457ad6a2ee920963e324bab25c4242db
            entity_id: sensor.lumi_lumi_weather_humidity_3
            domain: sensor
            below: 75
        sequence:
          - type: turn_off
            device_id: 7d74b7c8e812e444474b8c4f46021cde
            entity_id: switch.aqara_switch_module_ensuite_switch
            domain: switch

If the fan is left on, because the humidity is still high, I then have this automation thats supposed to ‘periodically check’ if the humidity is below 75 and turn the fan off:-

mode: single
trigger:
  - type: humidity
    platform: device
    device_id: 457ad6a2ee920963e324bab25c4242db
    entity_id: sensor.lumi_lumi_weather_humidity_3
    domain: sensor
    below: 75
condition: []
action:
  - type: turn_off
    device_id: 7d74b7c8e812e444474b8c4f46021cde
    entity_id: switch.aqara_switch_module_ensuite_switch
    domain: switch

This second automation is clearly not working because the fan only turns off when the 75 threshold is crossed.

I would simply use the humidity level to determine the amount of time to run the fan. Turn on the fan when the humidity increases above 75 (and remains above 75 for at least a minute) then turn off the fan when the humidity decreases below 75 (and remains below 75 for at least a minute).

alias: example 
trigger:
  - id: 'on'
    platform: numeric_state
    entity_id: sensor.lumi_lumi_weather_humidity_3
    above: 75
    for: '00:01:00'
  - id: 'off'
    platform: numeric_state
    entity_id: sensor.lumi_lumi_weather_humidity_3
    below: 75
    for: '00:01:00'
action:
  - service: 'switch.turn_{{ trigger.id }}'
    target:
      entity_id: switch.aqara_switch_module_ensuite_switch

For better performance, create a ‘deadband’. For example, turn on at 76 and off at 74.

Better yet, use the Generic Hygrostat integration. It’s intended for controlling humidification/dehumidification.

1 Like