Sonoff Tasmota and MQTT help

Hi all,
I’ve just installed my first Tasmota sonoff switch and configured in home assistant like this:

switch:
 - platform: mqtt
  name: "Sonoff 1"
  state_topic: "tele/sonoff1/STATE"
  value_template: '{{ value_json.POWER }}'
  command_topic: "cmnd/sonoff1/POWER"
  availability_topic: "tele/sonoff1/LWT"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online"
  payload_not_available: "Offline"
  retain: true

Everything work fine but the ui toggle gets updated after a few mins the availability command is sent.
Logs are highlighting an error parsing json:

error parsing value: ‘value_json’ is undefined (value: … template: {{ value_json[“POWER”] }}

It seems that the return of the command topic is not parsed properly.
I am running tasmota 5.12.0 20180209 and HA 0.65.6

Any help would be greatly appreciated.

Cheers,
Andrea

change into this:

switch:
 - platform: mqtt
  name: "Sonoff 1"
  state_topic: "stat/sonoff1/POWER"
  command_topic: "cmnd/sonoff1/POWER"
  availability_topic: "tele/sonoff1/LWT"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online"
  payload_not_available: "Offline"
  retain: true
1 Like

retain is true already as posted in my the configuration above.
I will change the value template and see how it goes.
Thank you very much.
AB

No it was specifically this line that was wrong
state_topic: "stat/sonoff1/POWER"

Working like a charm now.
Thanks a million!
/AB

1 Like