This is basically an LDR on A0 (Wemos D1 Mini) to detect is someone left the light on in the Attic.
The problem I am seeing is that at a random time the indicator_led turns off. But nothing in the downloaded logs show the value on A0 going below 80, let alone the threshold of 40. And, no matter the level at A0, the indicator_led will not turn on again until I cover the sensor forcing the A0 level below 40 then back above 40.
I think the āNo client connected to APIā was the problem. As I just learned a few days ago, the device has to be added to the integration in Home Assistant to keep the API connection live. So I added it to the integration and an hour later the issue hasnāt presented again.
I hadnāt added it to the integration because I was just experimenting and only watching the web_server output.
Someday I will do another experiment with an ESPHome device with no api: component. My guess is that the device was periodically checking for the API.
Thanks, I didnāt know that existed. There are times that I donāt want to configure a device into the ESPHome integration, like this experiment with an LDR sensor.
Bottom line, though, adding the device to the integration has solves the erratic behavior.