Accessing lastcheckin through $device


#1

My Xiaomi buttons intermittently stop working and have to be reset. Sometimes I don’t realise they’re misbehaving for days. I want to detect this as soon as possible as I use two of them as doorbells (triggering push message and lights flashing).

This might be academic as I’ve seen examples of people watching for offline status. However, I was already working on this and can’t get it working and so it would be good to know why.

When using a button by device name I can access the :lastcheckin property (?attribute). When using a list of devices in a for each the same property doesn’t work when accessed using $device.

In the posted example checkin_device has the correct time but checkin_variable contains the current time rather than last checkin time.

So, why can I not access the lastcheckin property of $device? And, was I barking up the wrong tree using this approach - is checking for offline status better?

Thanks


#2

I wrote this morning for someone. This might be easier to get type info your looking for