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

Template Sensor Problems

$
0
0

@weswitt wrote:

I’m running HomeAssistant 3.5 on a Raspberry Pi 3B+.

I’m having problems getting a simple template sensor to work. I’ve read the docs but cannot seem to make this work.

I have a sensor that is a discovered MQTT sensor. It has a JSON payload as the state value. In my tests the JSON state value is: { “temp”: “78.494003”, “humidity”: “24.537109”, “pressure”: “100561.515625”, “timestamp”: “2019-12-01T00:26:49Z” }.

I’m then trying to create a template sensor to extract the temperature value.

Using this properly yields the JSON string, which tells me that the template can access the value.

sensor:
  - platform: template
    sensors:
      upstairs_temp:
        friendly_name: "Upstairs Temperature"
        value_template: "{{ states('sensor.upstairs') }}"

Now if I do the following I get the “unknown” value.

sensor:
  - platform: template
    sensors:
      upstairs_temp:
        friendly_name: "Upstairs Temperature"
        value_template: "{{ state_attr('sensor.upstairs', 'temp') }}"

This also yields “unknown”:

sensor:
  - platform: template
    sensors:
      upstairs_temp:
        friendly_name: "Upstairs Temperature"
        value_template: "{{ sensor.upstairs.temp }}"

How do I make this work?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95513

Trending Articles



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