I just switched from deconz/phoscon to ZHA and one difference in particular hit me, both as food for thought and as a need to reconfigure my automations. The latter I’ve not yet found a satisfying solution to.
Using deconz my battery driven motion sensors had two states, binary, on or off, true/false.
Using ZHA they have three - on, off or unavailable.
Using deconz the battery sensor/attribute showed last known state.
Using ZHA the battery sensor is 90% in state unavailable.
This affected me in two primary ways - in lovelace using nothing but a glance-card and show_last_changed: true attribute I was able to see time since last actual movement in a certain room or rather for me more interestingly the period of no movement. Now with this same config the actual scenario is:
08:00 motion detected
08:05 no motion
11:00 device unavailable
If I then open HA at 11:30 it tells me last change was 30 minutes ago, which technically is true (off -> unavailable) but what I’m interested in is the span of 08:05 -> 11.30.
Secondly I have automations/alerts to warn me when batteries go low or bad/empty. This was an attempt at an amateur DIY home security system. And it worked quite well but now with ZHA I can’t differentiate a sleeping entity from one who’s batteries stopped working.
I realize I could dabble with template sensors to somehow emulate the deconz behavior but I’ve got so many entities it’d be a real chore to both implement and more importantly maintain.
I’m interested in knowing how other people in similar predicaments solves it and also if possible what the intended way is.
What I’ve tried to look for and was hoping to find is either a way to differentiate the state ‘unavailable’ as either sleeping or … hmm… not responding (?). Maybe that’s technically not feasible but I hope you get the gist of what I’m trying to convey. Secondly I was hoping to find some kind of “last_known_state” method. Maybe I’m stuck in my way of thinking, trying to force the ZHA-implementation to work in a way it wasn’t intended to. I understand why devices show up as ‘unavailable’ since they practically are unavailable to HA. But since they still work - as in, if the sensor is triggered it wakes up and sends an update, they, for me as a person, aren’t actually ‘unavailable’.