Switch state from tasmota mqtt, it worked then i broke it!

Hi all!

Should be an easy one, i had this working fine then was messing around with something else in config and lost it all. And the last backup was before adding the garage door config…

So i have an esp device running tasmota that controls my garage door with a relay and 2 limit switches to indicate open and closed thru mqtt.
I have 2 entities that would show the change, now i just get “unknown” on the entities.
unknown

When i listen to the topic of the tasmota i can see the limit switch states change.
as such -

Here’s the part from my configuration.yaml.
After i lost the working config, this is what i have remembered and i know ive forgotten something.
Can anyone spot the issue?
I could be completely wrong too haha
I suspect its in the value_json

  binary_sensor:
    - name: "Roller_Door_Open"
      state_topic: "tele/Roller_Door/SENSOR"
      device_class: garage_door
      payload_on: "Open"
      payload_off: "Closed"
      value_template: "{{ value_json.Switch2 }}"
    - name: "Roller_Door_Closed"
      state_topic: "tele/Roller_Door/SENSOR"
      device_class: garage_door
      payload_on: "Open"
      payload_off: "Closed"
      value_template: "{{ value_json.Switch3 }}"

Thanks!

Please format your code correctly: see here.

The switches are showing 'ON' or 'OFF' — why are you using "Open" and "Closed" in your sensor config? payload_on needs to be whatever the MQTT message (out of value_template) is for the switch to be on. Should be:

  payload_on: "ON"
  payload_off: "OFF"

…and I suspect one of those will need reversing as the switches are showing different things, open or closed.

I assume there’s a top-level mqtt: declaration ahead of the first line you’ve pasted?

Thanks for the quick reply, sorry about that new to the forum and forgot to format the code properly.

Heh that’s what it was, I don’t know what I was thinking with open and closed.
Changed to ON and OFF and all back to normal now.

Thank You!

1 Like

No problem. It’s not just regulars being picky: without the correct formatting, there could be all sorts of indentation errors lurking; and we can’t copy and paste your code to correct it as it’s got all the wrong quote marks once the forum software has processed it as text.

Glad it works now: fresh eyes are invaluable. You should get a rubber duck and explain each line of your code to it — that would also have exposed the bug.