Conditional Action

I want to turn a device on, but only if the temperature is low enough, but I don’t know what I’m doing wrong. Any help would be really appreciated.

  - service: |
      {% if states('sensor.master_bedroom_sensor_temperature') | int < 20 %}
        switch.turn_on
      {% endif %}
        entity_id: switch.blanket

It is easier for other users to give you relevant/reliable advise if you share the entire automation. Without the rest of the information to give this context I would suggest you look at Choose actions

Thanks. What I wasn’t sure about, with using Choose, is that, if the condition isn’t met, will the subsequent actions be carried out, or will the sequence just stop there?

When using Choose actions there are a couple things that could qualify as “subsequent actions”:

  1. Other Options within the Choose: These will only run if their conditions are met. Only the first Option (reading from top to bottom) whos’ conditions are met will run.
  2. Default Actions: These will run if none of the Options’ conditions are met
  3. Actions outside the Choose: These will run no matter what happens in the Choose action
1 Like

Good to know. Many thanks for that.