Testing and Debugging an automation

Hi, first post so apologies in advance if anything isn’t right, happy to amend and append if needed.

I have an automation that I would like to compare humidity in my kitchen and living room and start the extractor:

- id: '1596616404900'
  alias: Kitchen Humidity High
  description: ''
  trigger:
  - platform: time_pattern
    minutes: '/1'
    
  condition:
  - condition: time
    after: '07:00:00'
    before: '23:00:00'
    
  - condition: template
    value_template: "{{((sensor.humidity_kitchen) | float - (sensor.living_room_humidity) | float) > 9 }}"
    
  action:
  - service: homeassistant.turn_on
    entity_id: switch.kitchen_fan
    
  mode: single

Hopefully it’s clear what I’m trying to do; if the kitchen humidity rises compared to the living room between 07:00 and 23:00 then start the fan.

My question is, without actually steaming up my kitchen, how do I test this?
I’ve tried setting sensor.humidity_kitchen to 99 in the developer tools but nothing happens, so is this because I’m testing it wrong or because my automation is faulty?

If it’s the latter then any suggestions from the veterans here would be very much appreciated.

Many thanks in advance

Your conditions value_template is wrong.

Also, you are probably better of doing something like

trigger:
- plaform: template
  value_template:  "{{ (states('sensor.humidity_kitchen') | float - states('sensor.living_room_humidity') | float) > 9 }} 

Instead of triggering the automation every minute.

And just another small thing, since you seem like you are just starting this journey… You will save yourself a lot of frustrations if you already now begin to use a consistant naming scheme for stuff.
It does not matter what you chose, but at least from my own experience, things are much easier to work with if I use either the style “sensor.humidity_kitchen” OR the opposite “sensor.living_room_humidity” and don’t mix up the order of “room” and “sensor type” between them.

Olen, many thanks, that trigger looks a lot more sensible than what I was doing.
Good point re naming scheme, noted.

I’ll be honest, I’m finding the templating stuff a little confusing.
I did read the templating docs and I couldn’t find a working example of the type of comparison operation I’m trying to do.
I can see in your example that you’ve used

states('sensor.humidity_kitchen')

Will go away and RTFM a bit more :slight_smile:

Got it working, here’s the YAML for anyone trying to do something similar:

- id: '1596631620261'
  alias: Kitchen Fan On
  description: ''
  trigger:
  - platform: template
    value_template: '{{ (states(''sensor.humidity_kitchen'') | float - states(''sensor.humidity_living_room'')
      | float) > 9 }}'
  condition:
  - after: '07:00:00'
    before: '23:00:00'
    condition: time
  action:
  - data: {}
    entity_id: switch.kitchen_fan
    service: homeassistant.turn_on
  mode: single

Thanks for your help guys.

I snagged a bunch of Sonoff BasicZBR3 relays for peanuts on Gearbest so I’m going round making old, dumb devices a bit smarter starting with ventilation.

1 Like