Hello everyone!
When my relay is switched, I get the following messages on MQTT (the first is the switch command, the second the feedback from the relay)
maison-relay1/relay/0/set 1
maison-relay1/data {"relay/0":"1","time":"2018-04-04 13:38:34","mac":"68:C6:3A:A3:AD:46","host":"maison-relay1","ip":"10.100.10.118","id":2032}
I would like HA to understand the state of the switch via the JSON payload of the second line. To this, I added to the switch
section
- name: maison_relay1
platform: mqtt
state_topic: maison-relay1/data
command_topic: maison-relay1/relay/0/set
payload_on: 1
payload_off: 0
availability_topic: maison-relay1/status
state_format: 'json:"relay/0".value'
payload_available: "1"
payload_not_available: "0"
The state is not retained (or rather - acquired) when I switch the switch on (the switch button in HA goes to teh right, then comes back to the “off” state, which I assume to mean that the state was not acquired).
I believe that the problem is with the way the key relay/0
is to be addressed. My example is from the the JSONPath documentation which suggests using quotes.
I also tried to have payload_available: 1
and payload_available: "1"
(the latter being probably the correct one).
How should I address this?