User ID not set in Home Assistant Events sent from Node RED

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:

1 Like

Hey, did you ever find an answer to this?

I’m having a similar issue. I used to be able to get the user_id from a state node (for example to see which user armed the alarm system) but now the user_id is null (so is the parent_id). I haven’t found a fix to this.