Simple automation issue

So I have a simple setup.

A Zwave two outlet switch and a couple of wireless tag sensors.

The idea is that when temperature hits a certain threshold - it’ll kick on one of the two outlets and when humidity hits a certain threshold, the same will happen. So for now I’ve only started with the temperature portion to get it working and this is where I see problem. As it it doesn’t seem that anything triggers. I’m unfamiliar with troubleshooting so I do not know how to determine if HA is even playing nice.

Of note the sensors report in Celsius so I change it to Fahrenheit here. I’ve also tried this with “homeassistant.turn_on” instead of the service “switch.turn_on”

automation:
- alias: winecooler

  trigger:
    - platform: template
      value_template: '{{ states.sensor.wineador_upper_temp.state > 68 }}'
  action:
    service: switch.turn_on
    entity_id: switch.zooz_unknown_type2500_id2500_switch_2

  trigger:
    - platform: template
      value_template: '{{ states.sensor.wineador_upper_temp.state < 65 }}'
  action:
    service: switch.turn_off
    entity_id: switch.zooz_unknown_type2500_id2500_switch_2

Couple thoughts - haven’t tested but hoping I can push you in the right direction.

  1. I think you can specify an entity_id for your trigger so that it knows to re-evaluate the template when its state changes.
  trigger:
    - platform: template
      value_template: '{{ states.sensor.wineador_upper_temp.state > 68 }}'
      entity_id: sensor.wineador_upper_temp
  1. More likely is that you have an issue with the value being a string instead of an integer/float. So math doesn’t work as expected.
  trigger:
    - platform: template
      value_template: '{{ states.sensor.wineador_upper_temp.state | int > 68 }}'
      entity_id: sensor.wineador_upper_temp

Using the “int” filter (“float” would work, too) casts the value as an integer.

When diagnosing stuff like this, use the template dev tool. It’ll save you a lot of frustration. Dev tool buttons are at the bottom of your left-hand menu. You should see “{{ states.sensor.wineador_upper_temp.state | int > 68 }}” return “true” or “false”.

1 Like

Have you tested your value templates with the templates tool under developer tools on the front end? That will tell you whether or not your syntax is correct.

Also, it’s important to note that these automations will only fire once per crossing the of the threshold. E.g. the first one will only fire when the temperature goes from 68 to 69. If the temperature is already above 68 when you start up home assistant, it will not trigger.

Yeah that much I do understand - thanks!

@ih8gates

looks like I needed to change it to an int. we’ll see how this works out. thanks!