How can I detect after boot when the value of this sensor is synced with HA?
In other words: How can I discriminate the false state of this sensor from the state before any API connection has been established?
Basically I need an event that is triggered when the ESPHome log shows the Sending initial state message:
[09:09:22][D][binary_sensor:034]: 'Input boolean 'MCU Disable Sleep' from HA': Sending initial state OFF
I tried the events on_press, on_release and on_state but none of them does fire when the state is synced with HA after a boot of the MCU.
I know that I can monitor the API connection state using the api.connected condition, but I am sick and tired of the fact that I cannot use the normal debug log anymore, when I use api.connected as the log connection also counts as API connected. So while debugging the API condition is worthless to tell me when the binary_sensor becomes reliable.
publish_initial_state: true is the solution of my problem. It enables the events that were not working for me on first API connect.
I did not try the serial/USB solution. As I understand it, it requires an FTDI adapter and thus would not work once the MCU is hidden in the wall and only accessible OTA.