agittins / bermuda

Bermuda Bluetooth/BLE Triangulation / Trilateration for HomeAssistant
MIT License
460 stars 10 forks source link

Trackers 'not home' during HA restart show up as 'Unavailable' rather than 'away' #228

Closed dimatx closed 2 months ago

dimatx commented 3 months ago

Is your feature request related to a problem? Please describe. When I restart HA when the trash bins are already out, they do not show as away, but as 'unavailable'

Describe the solution you'd like If there is no signal from the tracker for some time, I'd like it to show as 'away' (or at least have the option to do that)

Describe alternatives you've considered Alternatively, I would treat 'Unavailable' as away in my automations.

Additional context Screenshot 2024-06-30 171209 Screenshot 2024-06-30 171343

agittins commented 3 months ago

Yeah, I think you're right.

Thus far Bermuda only creates an entity when it sees it appear in the cache of seen bluetooth advertisements, AND it matches the list of configured devices. This means a previously configured device won't be "created" on restart until we see a packet from it, so HA will treat the entity as unavailable (HA restores the entity on startup, but it remains unavailable until Bermuda "creates" it).

This will require a bit of an architectural change in how the startup works, so I'll need to think it through properly so I don't bork things up, but I'm on board for fixing this when I can make the time.

In the meantime, I'd suggest using tests along the lines of "entity state is home" and "entity state is not home" in your automations, rather than testing for "state is away".