Closed wilfredsmit closed 2 years ago
Hi, I would say it depends on how the sensor is internally handled by the HUE integration. It looks like the sensor is recreated from scratch each time, instead of updated.
Consider that the script only set the attribute value, creating the attribute if not exists.
It doesn't delete the attribute, unless you don't use the delete_attribute
action (which is not the case from what I'm seeing).
I'm afraid you need to adapt the trigger of your automation and set the attribute value for each sensor state change.
Oké, thanks for your explanation. Then I'll have to work my way around this behaviour. Nice script though!
👍
What is your question When I create a attribute on a binary_sensor that triggers the creation of the attribute, the attribute disappears after another state change of the binary sensor.
Is this by design? I would like the attribute to be permanent.
YAML configuration
Screenshots Animated gif!
Version v1.1.0
Additional information Logfile info:
2022-05-04 10:44:50 INFO (SyncWorker_2) [homeassistant.components.python_script] Executing hass_entities.py: {'log_enabled': True, 'action': 'set_attributes', 'entity_id': 'binary_sensor.hue_reserve_motion_lumi', 'attributes': [{'start': 1651653890.053345}]} 2022-05-04 10:44:50 DEBUG (SyncWorker_2) [homeassistant.components.python_script.hass_entities.py] Python Script: hass_entities.py -> START of action: set_attributes 2022-05-04 10:44:50 DEBUG (SyncWorker_2) [homeassistant.components.python_script.hass_entities.py] Entity: 'binary_sensor.hue_reserve_motion_lumi' -> New attribute 'start': '1651653890.053345' 2022-05-04 10:44:50 DEBUG (SyncWorker_2) [homeassistant.components.python_script.hass_entities.py] DONE -> Attributes set for entity 'binary_sensor.hue_reserve_motion_lumi' 2022-05-04 10:44:50 DEBUG (SyncWorker_2) [homeassistant.components.python_script.hass_entities.py] Python Script: hass_entities.py -> END of action: set_attributes