You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created the following HA automation to set the last seen attribute on all ZHA devices, similar to how zigbee2mqtt does. Think it will be informative to people as I couldn't find any other solution published anywhere.
@mdeweerd can you please add it to the docs where relevant?
alias: zha last seen attributedescription: set the last seen attribute on all entities of zha end devicestrigger:
- platform: time_patternseconds: "5"condition: []action:
- service: zha_toolkit.zha_devicesresponse_variable: dev_datadata:
command_data: last_seen,device_type,entities
- repeat:
for_each: "{{ dev_data.devices }}"sequence:
- condition: templatevalue_template: "{{ repeat.item.device_type == 'EndDevice' }}"
- variables:
last_seen: "{{ repeat.item.last_seen }}"
- repeat:
for_each: "{{ repeat.item.entities }}"sequence:
- service: zha_toolkit.ha_set_statedata:
attr_val: "{{ last_seen }}"state_id: "{{ repeat.item.entity_id }}"state_attr: last_seenmode: single
The text was updated successfully, but these errors were encountered:
mdeweerd
changed the title
add exmaple on how to set last seen attribute
Add example on how to set last seen attribute
Mar 14, 2024
I'll add it somewhere, probably to scripts - I need to think of a good way to add it to the readme as well (probably just 'Related examples:' in the proper section).
Any example will help, and this example is surely closer to what users expect.
I created the following HA automation to set the last seen attribute on all ZHA devices, similar to how zigbee2mqtt does. Think it will be informative to people as I couldn't find any other solution published anywhere.
@mdeweerd can you please add it to the docs where relevant?
The text was updated successfully, but these errors were encountered: