I have a ESPHome setup with a ultrasonic sensor that returns 1.5m if my car is parked and 3m if my car is not parked in the garage.
I would like to automate things if the state changes from parked to not parked and back (Turn on garage lights, etc). I’m thinking creating a custom state would be the way to go, but after googling I am quite confused as to how to proceed.
I’m assuming your sensor’s entity ID as it comes into HA.
That, as with all binary sensors, will have a state of on (parked) or off (not parked). You can then create automations from that.
You could create automations directly from the state of the ultrasonic sensor (trigger when it goes from greater than 2 to less than 2), but it’s a bit tidier like this.
Thank you so much, please excuse my ignorance, I have no idea where to add the template. If I add it to the device yaml, I get a lot of errors:
Many thanks
Yes. It’s a binary sensor, so its true states are on or off, but because you declared it with device_class: presence, the HA front end makes those to “Home” and “Away”.