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

Template Sensor troubleshooting

$
0
0

@nau wrote:

Hello

Looking for help with my gates sensor. I have PLC (Wago 750) connected to HA by Modbus TCP. I have a few inputs connected which have few states from a single sensor (Modbus_sensor): 252 (gates opened), 253 (gates closed), 254 (gates malfunction), 255 (gates in progress). Those statuses i’m able to read in sensor.gates. If I put code into http://localhost:8123/developer-tools/template, then statuses will be displayed as well correctly (Opened, closed and etc):

          {% if is_state('sensor.gates', '252') %}
            Opened
          {% elif is_state('sensor.gates', '253') %}
            Closed
          {% elif is_state('sensor.gates', '254') %}
            Malfunction
          {% elif is_state('sensor.gates', '255') %}
            Progress
          {% else %}
            failed
          {% endif %}

But if I put final code to configuration.yaml file:

sensor:
  - platform: template
    sensors:
      gates:
        value_template: >-
          {% if is_state('sensor.gates', '252') %}
            Opened
          {% elif is_state('sensor.gates', '253') %}
            Closed
          {% elif is_state('sensor.gates', '254') %}
            Malfunction
          {% elif is_state('sensor.gates', '255') %}
            Progress
          {% else %}
            failed
          {% endif %}

I’l get only “failed”

What I’m doing wrong?

Posts: 6

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95314

Trending Articles



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