I’m a newbie, giving frist steps in HA’s matters. At this point I’m struglling to setup up my shelly devices throw MQTT protocol. I’ve intalled mosquito brocker and mqtt’s integration and configured out one of my shellies (in this instance i’m using a Shelly plus 1pm gen2). I 've checked thow MQTT explorer that my shelly device is communication to my brocker, sending at every minute info. At this point I’ve got 2 issues: 1st one MQTT auto discovery is not working as it’s not found my shelly (using the Shelly integration, the relay is detected with no problom), the 2nd one when trying create the yaml file to provide the entity into my HA, i’m facing some problem which are beyound my understading…
I’ve created a yaml proper file named mqtt.yaml with this code:
In addition, change QoS to qos. Options are in lower case. Similarly, the value of unique_id should be a slug (which means lower case letters and numbers and underscores only). Refer to the examples in the MQTT Switch documentation.
thanks for your prompt reply. Never thought in a syntax issue. I’ve just got another issue: just realise that my shellies is publishing in json format, my question here is how specify that in my yaml file.
This should work for receiving the device’s current state.
state_topic: ILdeck/status/switch:0
value_template: "{{ 'ON' if value_json.output is true else 'OFF' }}"
However, for sending a command to the device, I first need to know the command’s format. What does the device expect to receive via the topic ILdeck/command/switch:0?
command_topic: "ILdeck/command/switch:0"
command_template: <to be determined>
Hi mate, huge thanks! the status is working perfectly. Regarding the command. I gave a command using the shelly official integration and what shelly pusblish into the broker is the changing of output var from false to true.
At input:0 one I’ve connect a lighting sensor. don’t need integration with HA propely.
I’ve tried the solution you suggest me however the entired string is replaced by the boolean when I shoot the commad. Is there any way of replacing only the the output var? I tested a json string like the one you provided me for the status but the only thing I got it was a parsing template error.
btw. My conclusion concerning the command topic seems to be the same that the status one, once it’s the only var where i can see changings when turn on/off the command (using the official shelly integration for that). Make any sense?
That’s it mate. Thanks a lot. Just a note for whoever can be following the topic: it’s needed change the on/off at state template to lowercase otherwise it’s not possible getting the state from Shelly.