Esphom for car presence

Hi experts,

I have been using GitHub - aderusha/MQTTCarPresence: WiFi device to announce the presence of a car for garage door automation · GitHub for a few years on some esp8266’s, but they seem to be dying out so I wanted to modernize this solution a little bit. I wanted to try to redo this code using esphome, but am getting stuck on a few pretty important points.

  1. I can’t find a way to have HA not show the entities as unavailable when the esp32 is powered off. I need to have the signal strength retained, and ideally have the state be off instead of unavailable.

  2. I can’t figure out if I should be using the api or mqtt for this. I’ve tried both, but neither seems to work.

I’ve been playing around with the last will, retain, availability settings, and nothing I can find seems to work. chatgpt is next to useless for this sort of stuff, it just gives me complicated lambda functions that don’t compile.

HA will always show unavailable if it lost connection.
Having it retain the values are false values and that is why it says unavailable.

If you want to keep the values then a template sensor will work unless you reboot HA.
You create a template sensor to essentially ignore unavailable. But if HA reboots then it will become unavailable.

To solve that you would need to use an automation and input_* helpers.
Trigger the automation on a value becoming unavailable and set the value of the helper to what it was prior.
Input helpers retain their values past a HA restart so these will stay.

so basically esphome sucks for this use case and I should stick with my arduino version?

Not at all.
It is unknown. Saying it’s not unknown would be lying.

My use case requires having the last known value of the wifi signal strength. So yes, esphome would not work for this use case if it is automatically going to mark it as unknown.

The state is what the current value is, and the current value is unknown. Your use case is not what is normal in a smart home.
Relying on old unknown, presumed states just makes no sense.
But you can as I said before make it work.

1 Like