Not getting state from Tasmota on mqtt

I have a Tasmota POW setup and getting sensors values ok and the switch can be controlled but I am not getting State updates.

mqtt:    
  switch:
      name: "Waterpump Switch"
      state_topic: "stat/sonoff2/power"
      command_topic: "cmnd/sonoff2/power"
    #   availability:
    #     - topic: "stat/sonoff2/power"
      payload_on: "ON"
      payload_off: "OFF"
      state_on: "ON"
      state_off: "OFF"

I have tried setting the availability topic as commented out above. This changes the default icon but the switch then fails to respond.
Not sure what I am doing wrong. I tried adding a value_template:

value_template: '{{ value_json["POWER"] }}'

but no success.
The Sonoff console shows responses like this:

10:33:01 MQT: stat/sonoff2/RESULT = {"POWER":"ON"}
10:33:01 MQT: stat/sonoff2/POWER = ON

Any clues for what I am missing?

Is there any reason you are not using discovery to automatically add your devices?

I guess I wanted to understand what was involved in getting it to work but I do take your point.
Would discovery work on an old 6.2.0 version of Tasmota FW? I haven’t touched this sort of thing for about 4 years. Usually multiple steps to update and happy to avoid if not necessary.

Ok. That wasn’t as painful as I expected. Now on version 12.3.1 and discovery worked in HA. So now I can remove a bunch of lines from config.yaml
Thanks!

1 Like