I’m struggle since days.
The setup:
esp32 with PubSubClient publishing mqtt msg
HomeAssistant
I have created an mqtt switch in the configuration.yaml.
I added a button on the dashboard, but it say as status “unknown” and not sending other then “off” mqtt msg.
but with mqtt explorer it is visible the esp32 send properly the feedback on the right topic.
So I added a button and a entity switch like on the picture.
with this Optimistic: false setup the BUTTON only sends OFF payload. If I change the Optimistic to true, the BUTTON toggles between ON and OFF, but it is never show the real status(below the “Garage” title it is always unknown) what is sent by the esp32
And maybe I missed to mention an important thing. What I want to achive
I would like to make a toggle switch of this like the picture above the “Garage relay”
and in case of I make a BUTTON of it I would see my custom state what is broadcasted from the esp32 like under the Heating Button “Off” but I would have have here instead of “Off” Closed or Opening or anything custom text.
That’s not a toggle switch. That’s specifically a switch which doesn’t have a state, so that you have to click on the “on” or “off” button.
What is the actual content of the eps32/garage/switch/status topic?
The way you used state_on / state_off, it must contain “Open” or “Closed” (case-sensitive)
Thank you koying for the reply.
the content of the esp32/garage/switch/status is “Open” or “Closed”, this is what I send through mqtt from the esp32. like above in my code. so it is identical
I have checked it with Mqtt explorer as well and it gives back Open or Closed.
in my configuration.yaml I also tried it with quotation marks and without them, but nothing changed
and it works as expected, from esp32 each 10 sec it send the WiFi signal strength. So my understandig the information from esp32 come through as it should be, but somehow on broker side I don’t handle it right in with the switch configuration.
Thank you koying for your support and you tried to help me, meanwhile I found out the issue. It is so unbelivable, I spent how many hours to investigate what is the issue and then the issue was A TYPO
instead of “esp” I wrote “eps” in the configuration.yaml. in mqtt explorer and in mqtt listener I typed in write so I seen the communication is proper. It was so dumb error.