Help with automating humidifier based on numeric_state

Hi all,

I’ve been researching a simple way to automate a humidifier to turn on and off based on the numeric state from a humidity and temperature sensor. Essentially, I want the humidifier to turn on if the humidity is lower than 40%, then turn off when 65% has been reached. I’d like to keep it to a single automation if possible.

I have a Govee H&T sensor and a Levoit humidifier that I’m trying to get to play nice together here. YAML in HA isn’t my forte (I’m no developer, but I could probably do it in PowerShell lol), so I struggle with some specific tasks. Any tips would be greatly appreciated.

No need to do Yaml, your automation can be created solely from ui.

Use two numeric state triggers (one for above and one for below). Assign each trigger an ID. In the automation’s action part, use the „Chose“ branching to react on the trigger id.

But what if I wanted to use YAML instead? In some circumstances I find the UI is limiting and I can’t figure out how to achieve the end result this way.

To give a little color on this, here’s my setup. I have an indoor grow tent for vegetables and two lemon trees. Every time the exhaust fan runs it also draws out the humidity. The fan automation is configured to run for 20 minutes every even-numbered hour.

I’ve noticed that after the fan has been running for 5-10 minutes during this period, the humidifier kicks on and that water is essentially wasted as it’s sucked up in the exhaust.

My end goal is to have the two work together. For instance, run the humidifier as needed during the fan’s downtime, but ignore thresholds during the times while the fan is running.

Below is the fan automation:

- id: '1640328687794'
  alias: Grow Tent Fan Schedule
  description: ''
  trigger:
  - platform: time_pattern
    hours: /2
    minutes: '0'
    seconds: '0'
    id: 'on'
  - platform: state
    entity_id: switch.grow_tent_fan
    from: 'off'
    to: 'on'
    for: 00:30:00
  action:
  - service: switch.turn_{{ 'on' if trigger.id == 'on' else 'off' }}
    target:
      entity_id: switch.grow_tent_fan

Feel free to do so. You can even turn the editor into Yaml mode and still get some feedback on errors.

I guess my question is, how would I code this? I’ve done some research and found a few snippets, but I don’t have time go down the proverbial rabbit hole.

Hmm … how about:

  • as first action in the fan’s automation, disable the humifier’s automation.
  • run the fan
  • enable the humifier’s automation again (which will probably make him start immediately).

I got something like this which works well.

- alias: Humidifier between 40 to 65
  trigger: 
    - platform: numeric_state
      entity_id: sensor.ble_humidity
      below: 40
    - platform: numeric_state
      entity_id: sensor.ble_humidity
      above: 65     
  action:
    - service: "humidifier.turn_{{ 'off' if states('sensor.ble_humidity') | float > 65 else 'on' }}"
      entity_id: humidifier.zhimi_humidifier_v1
    - service: "humidifier.turn_{{ 'on' if states('sensor.ble_humidity') | float < 40 else 'off' }}"
      entity_id: humidifier.zhimi_humidifier_v1