jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
196 stars 48 forks source link

Record the last time an update was received for a device #101

Closed jason0x43 closed 3 years ago

jason0x43 commented 3 years ago

Provide a last_updated attribute for entities, or a last_updated entity for devices, that shows the last time an update was received from the hub. This would be useful for determining if a device has become unresponsive.

edalquist commented 3 years ago

Is there documentation how to add this attribute to my existing entities?

jason0x43 commented 3 years ago

Oops, I meant to add documentation before closing this...

The current implementation provides "last update time" sensors for every device, disabled by default so as not to clutter things up. For example, say you have a "table lamp" light device. The integration will create a light.table_lamp entity for that device, and maybe a sensor.table_lamp_power sensor if the device supports power metering. With this update, the integration will also create a sensor.table_lamp_last_update_time entity for the lamp.

The "last update" sensors are device-level sensors rather than entity attributes because the main use case is to detect non-responsive devices. A device may have multiple entities, and at the device-level, any of them being updated counts as activity.

edalquist commented 3 years ago

Found it. Is there a way to switch the default state of these *_last_update_time sensors to enabled? I've been wanting to set up dead-device detection in HA for a while and would love to blanket enable this instead of having to go through each device to enable the sensor.