MQTT Switch Queries

Hi All,

I’ve recently setup a 4 outlet smart power strip running Tasmota using the generic MQTT Switch entity type, the switches themselves appear to be working correctly in every way but there look to be a couple of issues within HASSIO which I’d like to tidy up if possible.

Each of the switches is setup in exactly the same way as per below -

switch:
  - platform: mqtt
    name: "USB"
    state_topic: "stat/SM-S0301_Bedroom/POWER1"
    command_topic: "cmnd/SM-S0301_Bedroom/POWER1"
    value_template: "{{ value_json.POWER1 }}"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    retain: true 

My first query is: In the Developer Tool logs, there is an error for each of the switches Error parsing value: ‘value_json’ is undefined (value: OFF, template: {{ value_json.POWER1 }})

This error is occurs any time I interact with any of the switches, despite the hardware responding exactly as you’d expect.

My second query is: While the switches appear in the UI and work fine, there are no devices displayed under the MQTT integration tab, nor do any of the switches appear in the entity registry so the only way I can change details is through the raw config - is this correct?

That is normal for manual configured MQTT devices. If you want to make them appear there, you have to enable auto discovery. This will solve your other problem too : in the tasmota console, just type SetOption19 1

Awesome! Thanks for the tip, that’s fixed both issues.

You will want to get rid of the retained messages as well probably. Use something like MQTT Explorer.
If you don’t fix that you will find that the switches will randomly switch on say if there is a MQTT reconnect or WiFi reconnect.