HA Connected Sensor

Does anyone know how to create a binary sensor within an ESPhome device that tracks the connection to the Home Assistant API? i.e. one which is true when connected to HA but then goes false if HA is rebooted or otherwise goes offline and then becomes true again upon reestablishing a connection.



Unless I’m missing something obvious, a sensor is not going to change when HA is rebooting because, well, HA is rebooting, and once it’s rebooted your sensor would show everything is running. Maybe you could do something with uptime (https://www.home-assistant.io/integrations/uptime/) or even https://www.home-assistant.io/integrations/uptimerobot/ .

EDIT: Yes I was missing something, this is in the esphome section, and I know very little about esphome, so my advice may well be incorrect, but leaving it here just in case :grinning: .

I don’t think he’s talking about a HA sensor, but about an ESPhome sensor. One that would run on the esp.

I was referring to a sensor within an esphome device, not home assistant. I will update my original post to clarify. Thanks fir the response.


:smiley: I realised that as I clicked post, but didn’t get the edit in before there were two responses confirming I had missed the point!

HA offline : I don’t know.

HA restarting : you could use the mqtt sensor

HA publishes to hass/status ‘offline’ when stopping, and ‘online’ when started again.


There is a binary sensor for that:

Oh nice, didn’t know about that one. Thanks!!!

1 Like