I am programming my home automations with Node RED. I want to be able to manually override automations, for example by controlling accessories through HomeKit Controller or the Home Assistant Dashboard.
To detect manual overrides, I set up Node RED using its own Home Assistant user.
Then, I added a events: state node for the respective accessories and I am using a switch node that branches based on msg.data.new_state.context.user_id
, where msg.data
is the event data coming from Home Assistant. When it is set to the user id of my Node RED user, then I know that the source of that event is some automation and otherwise, I know that the event originated somewhere else. For example, when I control the accessory through the Home Assistant Dashboard, I get my personal Home Assistant user id, when I control the accessory through HomeKit, I get null
.
However, sometimes, when controlling the accessory through a Node RED flow, msg.data.new_state.context.user_id
is also null.
Why is this the case and how can I work around that?
Are there other solutions for distinguishing manually triggered events from Node RED events?
Configuration:
- Home Assistant 2022.7.5
- [email protected]
- [email protected]
- Accessories: Various Philips Hue devices, using Home Assistant Hue integration.