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

MQTT value_template and value_json understanding

$
0
0

I’m not understanding this section of the help page.

The example shows, the value_json.on (references the “on” in the msg?) grabs the value “true”? So I thought I would duplicate this in mine, but I get the error below.

My MQTT sensor:

  - platform: mqtt
    unique_id: '123456HomeAssistantShutDown'
    state_topic: "homeassistant/CMD/shutdown"
    value_template: "{{ value_json.cmd }}"

My MQTT payload:

{"type":"HA","cmd":"SHUTDOWN"}

When I send that msg I get this error in the logs:

Logger: homeassistant.helpers.template
Source: helpers/template.py:1791
First occurred: 12:22:40 PM (1 occurrences)
Last logged: 12:22:40 PM

Template variable error: ‘value_json’ is undefined when rendering ‘{{ value_json.type.cmd }}’

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 105913

Trending Articles



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