Automation of a dehumidifier

Hello,

I have a humidity detector (netatmo weather station) and a smart plug. I am trying to have the plug switch on when the humidity is above a certain threshold.

I have the following automation script:

- id: '1645635419247'
  alias: Humidite_Cave_above_58
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.netatmo_home_indoor_cave_humidity
    from: '58'
  condition: []
  action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.cave
  - service: notify.notify
    data:
      message: DĂ©shumidificateur de la cave en marche.
      title: DĂ©shumidificateur
  mode: single

The sensor is now at 59%, but the switch did not switched on.

Any idea ?

Thanks

Philippe

I’m not sure from is the correct approach here. Either look at using a numeric_state trigger and above: 58 or perhaps use the Generic hygrostat.

You can use state but I would leave both to: and from: blank and use a condition for the threshold.

Also be aware that if the current sensor value is already above the trigger threshold, it will not trigger. The trigger is only caught when crossing the threshold.

You should be able to trigger it with device and set it above 58. I do that for light levels.

alias: New Automation
description: ''
mode: single
trigger:
  - type: illuminance
    platform: device
    device_id: abb4d429f6052aa15783077df42408ad
    entity_id: sensor.kitchen_lux_bh1750_illuminance
    domain: sensor
    above: 58
condition: []
action:
  - device_id: ''
    domain: ''
    entity_id: ''

Thanks. Indeed, this is why I used “state” (I though it would launch the script if the sensor is in a certain state i.e. above 58%). The thing is that I would like to add a condition that it does not trigger at night.

I was under the impression that if I put this condition, then, if the sensor goes above 58% during the night, it would also not trigger during the day (since already above 58%).

I have to conditions for the switch to goes on: 1. time is between 8:30am and 5pm AND 2. the humidity is above 58%.

Thanks

This will work with a state trigger if you leave the to and from blank and include those conditions :slight_smile:

As others have mentioned, you need to use a numeric state trigger. Using a state trigger in cases like this requires that the sensor’s value hits 58% exactly… not 57.9% or 58.1%, exactly 58%. The numeric state trigger allows for “above” and “below”.

But you also need to incorporate other triggers to handle the case you mentioned:

As well as to handle turning it off. Like the “turn on” part, you need to account for turning it off based both on humidity and on time.

- id: '1645635419247'
  alias: Humidite_Cave_above_58
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.netatmo_home_indoor_cave_humidity
    above: '58'
    for:
      minutes: 1
    id: 'on'
  - platform: numeric_state
    entity_id: sensor.netatmo_home_indoor_cave_humidity
    below: '57'
    for:
      minutes: 1
    id: 'off'
  - platform: time
    at: "17:00:00"
    id: 'off'
  - platform: time
    at: "8:30:00"
    id: 'on'
  condition: []
  action:
  - choose:
    - conditions:
       - condition: trigger
         id: 'on'
       - condition: numeric_state
         entity_id: sensor.netatmo_home_indoor_cave_humidity
         above: '58'         
       - condition: or
         conditions:
           - condition: time
             before: "17:00:00"
           - condition: time
             after: "8:30:00"
      sequence:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.cave
      - service: notify.notify
        data:
          message: DĂ©shumidificateur de la cave en marche.
          title: DĂ©shumidificateur
    - conditions:
      - condition: trigger
        id: 'off'
      sequence:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.cave
  mode: single

The automation above will turn it on between 8:30am-5:00pm when the humidity goes from below 58% to above 58%. In case the humidity is already over 58% at 8:30am, there is a trigger at that time as well.

It also handles turning the dehumidifier off when the humidity hits below 57% as well as a timed turn off at 5pm.

2 Likes

Correct. The issue of your original code is that the temperature would have to move from exactly 58 so that to trigger actions.

Meaning, if your sensor reporting 57.9, and then the next reading being 58.4, it would not trigger.
Also even if your sensor reporting 58.0, it would not trigger either… because 58.0 is still not exactly 58.

Thanks for your help !
Cheers
Philippe