I am getting frustrated because there seems to be nowhere explained just how Mqtt is designed/configured in relation to automatic transfer of sensor and other states from esphome to homeassiatant. I understand that you can do this explicitly in an automation but there also seems to be some sort of transfer that takes place in certain circumstances without explicit calls to Mqtt in the configuration. Can someone explain when I can rely on esphome transferring the states using Mqtt on its own and when I need to do it myself explicitly. Thanks in advance
If esphome is configured for mqtt, then when a sensor value is updated in esphome, eg if a temperature changes, esphome sends the state to mqtt which updates ha. Instantly.
Thanks nick rout I saw one of your other posts as well. I think my problem is that binary sensors seem not to be automatically published - at least that is my experience here is a snippet of my esphome code (sorry I don’t know how to format it properly in the forum!!)
This switch is sent to esphome correctly
- platform: gpio
id: M5_BtnB
pin:
number: 38
inverted: true
on_click:
then:
- switch.toggle: backlight
switch:
- platform: gpio
pin: 32
name: "Backlight"
id: backlight
restore_mode: ALWAYS_ON
But if you have another button on its own with no switch attached I don’t think its sent
- platform: gpio
id: M5_BtnC
pin:
number: 39
inverted: true
What’s frustrating is that if you look at Mqtt explorer the debug shows a message when the button without a switch is changed but there is no specific message for the button without a switch ( I was looking for a topic like M5_BtnC
For me the documentation is hard to follow or quite sparse. Despite the popularity of esphome and home assistant and Matt there are not a lot of examples I could find to illustrate how the automatic publishing in esphome works. I guess when I get motivated I will try to rectify this
I think you have to define a name
for the switch. If you specify an id
without a name
it is marked as internal. And will not be exposed to the frontend.
Have a look at the documentation for binary sensor.
Thanks Dylan_09 your a champion