Humidity Automation Not Working

I cannot figure out why the following automation is not working. I have restarted HA several times and ensured the ranges drop below to reset accordingly. What am I doing wrong?

id: "1732760906762"
  alias: Main Dehum
  description: Turn on dehum when above 50% humidity for 10 minutes, off below 48%
  triggers:
    - entity_id:
        - sensor.i_9psl_humidity
      for:
        minutes: 10
      above: 50
      id: "on"
      trigger: numeric_state
    - entity_id:
        - sensor.i_9psl_humidity
      for:
        minutes: 10
      below: 48
      id: "off"
      trigger: numeric_state
  actions:
    - target:
        entity_id: switch.attic_esp32_dehum_main
      action: switch.turn_{{ trigger.id }}
  mode: single

Hello

I am guessing, but at anytime you were testing, did the humidity pass thru 50% or 48% and stay there for 10 minutes? It actually has to have data points on both sides of the trigger point you set.

In addition to the questions from @Sir_Goodenough , how exactly is it not working? What have you done to test it?

The test I ran worked fine with my entities and a 30 second time frame. I would take @d921 advice and do some testing.

You can force the high and low state of your humidity sensor using Developer Tools.

My Test Automation

alias: Main Dehum
description: Turn on dehum when above 50% humidity for 10 minutes, off below 48%
triggers:
  - entity_id:
      - sensor.living_room_humidity
    for:
      seconds: 30
    above: 50
    id: "on"
    trigger: numeric_state
  - entity_id:
      - sensor.living_room_humidity
    for:
      seconds: 30
    below: 48
    id: "off"
    trigger: numeric_state
actions:
  - target:
      entity_id: switch.kitchen_lights
    action: switch.turn_{{ trigger.id }}
mode: single

The problem as ever is you are triggering above a certain value, this will only trigger when the value changes from below to above. If it is already above it will never trigger.

You need to trigger on a numeric state change (with no values) then use condition for the humidity value.

Have you tested your theory? Two triggers will separate the logic for above and below.

Yes loads of time just try it.

I did with this

alias: Main Dehum
description: Turn on dehum when above 50% humidity for 10 minutes, off below 48%
triggers:
  - entity_id:
      - sensor.living_room_humidity
    for:
      seconds: 30
    above: 50
    id: "on"
    trigger: numeric_state
  - entity_id:
      - sensor.living_room_humidity
    for:
      seconds: 30
    below: 48
    id: "off"
    trigger: numeric_state
actions:
  - target:
      entity_id: switch.kitchen_lights
    action: switch.turn_{{ trigger.id }}
mode: single

Heck test it with a light as the trigger using the brightness attribute

alias: dehum 2
description: Turn on dehum when above 50% humidity for 10 minutes, off below 48%
triggers:
  - entity_id:
      - light.pc_lights
    for:
      hours: 0
      minutes: 0
      seconds: 5
    above: 50
    id: "on"
    trigger: numeric_state
    attribute: brightness
  - entity_id:
      - light.pc_lights
    for:
      hours: 0
      minutes: 0
      seconds: 5
    below: 20
    id: "off"
    trigger: numeric_state
    attribute: brightness
conditions: []
actions:
  - target:
      entity_id: switch.kitchen_lights
    action: switch.turn_{{ trigger.id }}
mode: single

Did you read the link Sir-goodenough posted? Did you understand it?

Aer you serious? Did you test the example automation I posted? It works fine so please explain your point with additional facts.

Untitled video - Made with Clipchamp

It wont, if the humidity is above 50 when you restart HA it will not run. If the lights are on when HA restarts and the humdity is less 20 the lights will stay on. If your sensor becomes unavailable whilst the threshold is past in either direction the automation will not trigger. But hey if you insist on doing it that way feel free.

Have you considered using the Generic Hygrostat integration to control the dehumidifier’s operation?

It creates a climate entity that, once set to a desired humidity level, will automatically turn the dehumidifier on/off to maintain the desired humidity.

generic_hygrostat:
  - name: Attic Dehumidifier
    humidifier: switch.attic_esp32_dehum_main
    target_sensor: sensor.i_9psl_humidity
    min_humidity: 40
    max_humidity: 60
    target_humidity: 50
    dry_tolerance: 2
    wet_tolerance: 2
    device_class: "dehumidifier"
    min_cycle_duration:
      minutes: 5