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

Help with value_template and conditional 'if'

$
0
0

@sernafa wrote:

Hi, I need some help with configuring this senson with rest and value_template. In my configuration.yml file:

  - platform: rest
    resource: http://localhost:3000/api/v1/hvac
    json_attributes:
      - data
    name: airzone
    method: POST
    payload: '{"systemID":1,"zoneID":0}'
    scan_interval: 60
    value_template: 'OK'
  - platform: template
    sensors:
      blueface_status:
        friendly_name: Status
        value_template: {{ states.sensor.airzone.attributes.data.0.on }}

{{ states.sensor.airzone.attributes.data.0.on }} show values 0 or 1, depending on the operating status. It’s ok.

Is it possible to use an ‘if’, as an example although it is incorrect, to be able to show “running -> 1” and “stopped -> 0”?

Ex:

        value_template: >-
-->      {% if {{ states.sensor.airzone.attributes.data.0.on }} == '1' %} <--
            Running 
          {% else %}
            Stopped
          {% endif %}

Thks in advance.

Posts: 5

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 101976

Trending Articles



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