Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 102594

Can't seem to get syntax for if-then-else template to work

$
0
0

@prexer wrote:

I can get a basic automation to turn the fan off, on, or set a speed, but when I try to get it all into one automation that sets the fan speed based on the temperature differential between upstairs and downstairs, it doesn’t seem to work. I’m assuming there’s something wrong with my templating syntax, but I can’t seem to get it ironed out.

automation:
  - alias: fans to different speeds
    trigger:
      platform: time_pattern
      minutes: "/1"
    action:
      service: fan.set_speed
      entity_id:
        - fan.kitchen_fan
      data_template:
        speed: >
          {% if (abs(climate.main_floor.current_temperature - climate.upstairs.current_temperature) <2) -%} off
          {%- elif (abs(climate.main_floor.current_temperature - climate.upstairs.current_temperature) >5) -%} 4
          {%- else -%} 2 {%- endif -%}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 102594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>