I am using MQTT lights on JSON Schema for a while now and I like issuing commands and receiving response/status in JSON format eg. {"state": "ON"} / {"state": "OFF"}.
I wonder if it is possible to use JSON format also fot the MQTT switch. For the state I managed to parse it with: value_template: '{{ value_json.state }}'. But I do not have an idea how to issue a command in JSON format trough command_topic…?
For now I use MQTT Lights also for other switches, but it does not seem really the right way to do it, but it works
Hmm, I think I figured it out . It works with defined payload_on/off and state_on/off.
I tried it before but I had problems with quuotation… this is my working config: