Condition Problems

Hi, Started using HA this week, been happily adding my devices and now looking at automation’s.

I have an evohome system, which I’m creating sensors from for the setpoint and temperature of my bedroom, plus the outside temperature and then I’m trying to use this to switch on a fan using a meross smart switch.

However, every time I trigger the automation, the action always triggers. The outside temp is >17 as I write this and it still turned the vent switch on. What am I doing wrong? Current version of the code below:

- alias: Bedroom Vent On
  - platform: time_pattern
    minutes: /3
    condition: and
      - condition: template # Bedroom above 17
        value_template: "{{states('sensor.bedroom_temperature') | float > 17}}"
      - condition: template # Outside below 17
        value_template: "{{states('sensor.weather_temperature') | float < 16}}"
      - condition: template # Evohome not heating room
        value_template: "{{states('sensor.sensor.bedroom_target_temperature') | float < 17}}"
   - service: switch.turn_on
      entity_id: switch.meross_1903263838868125183834298f1dbf40

Results of the value templates:

{{states('sensor.bedroom_temperature') | float > 18}}                      
{{states('sensor.weather_temperature') | float < 16}}
{{states('sensor.sensor.bedroom_target_temperature') | float < 17}}


First of all, why don’t you make ONE template condition like:

  condition: template
  value_template: >
    {{states('sensor.bedroom_temperature') | float > 17 and states('sensor.weather_temperature') | float < 16 and states('sensor.sensor.bedroom_target_temperature') | float < 17}}

Second, you have an error here


compare to the other two sensors.

Paste it in template editor and check.
Please correct the above and try your automation. Just keep in mind that if you trigger your automation manually, HA DOES NOT check condition, it just executes action (and that’s probably why your action always executes).

Thanks Ahmad,

I have it working now, with the logic in a single value_template. I would never have guessed that the manual trigger ignores the conditions… That explains a lot. :slight_smile:

1 Like