Hi, I have a zigbee switch managed through Z2M. For some reasons, at some times the switch switches on automatically. I narrowed it down to it to happen when one member of the family switches to home. However, I have double-checked both node-red and HA automation and I could not find anything related to it.
Is there a way to know which component caused the switch to switch on? In the log I simply see “Supervisor”
I would start by checking the context ids to see which other state objects were touched in the same context. For example, if I run this code in Developer Tools > Template:
{% set entity_id = 'light.toilet_ceiling' %}
{{ states | selectattr('context.id', '==',
states[entity_id].context.id)
| map('attr', 'entity_id') | list }}
{{ states | selectattr('context.id', '==',
states[entity_id].context.parent_id)
| map('attr', 'entity_id') | list }}
{{ states | selectattr('context.parent_id',
'==', states[entity_id].context.parent_id)
| map('attr', 'entity_id') | list }}
Based on this information, the last thing that happened is that my occupancy sensor binary_sensor.toilet_occupancy triggered the automation automation.toilet_occupancy_clear – the automation’s context.parent_id is the same as the sensor’s context.id. The automation in turn did something to the lights light.toilet_ceiling and light.toilet_mirror (turning them off) – these entities context.id and context.parent_id all match.
Of course you need to run this template (modified for your entity id) at the time the light has just turned on unexpectedly. AFAIK you cannot recall previous state objects, except for maybe if you’re a wizard with SQL and can query the state machine database directly.
I would interpret that as some major event occurring which caused all entities to update at the same time. Possibly HASS crashed and restarted, or the MQTT broker, or the Zigbee backend… Isn’t there anything at all in the logs?