I have an MQTT sensor as follows:
78 . - name: "Home Electricty"
79 . . object_id: "electric_panel"
81 . . state_topic: "electric_panel/datatest"
84 . . value_template: "{{ value_json.status }}"
85 . . json_attributes_topic: "electric_panel/datatest"
86 . . json_attributes_template: >
87 . . . {
88 . . . . "voltage1": {{ value_json.voltage1 }},
91 . . . . "current1": {{ value_json.current1 }},
94 . . . }
This works for the most part, but there’s something a little weird to me.
If I make my mqtt message that’s carrying my json data come in, and the “status” in my json object is { “status”: 1}. All my other json values are numbers, and it works fine.
But if I change my json to { “status”:“on”}. Then nothing works. It doesn’t pick up on any of the attributes. Why does it do this? And I can’t figure out how to fix it.