I've spent a lot of time trying different approaches and haven't been able to figure this out so far.
I've got a flow for an alarm system which uses Zigbee2mqtt running under Home Assistant, some Ikea buttons and some Xiaomi vibration sensors, and it all works fairly well.
As part of the flow, I set a Context Data Flow variable "alarmActive" (in file) and am using a Switch node to successfully read the boolean value and enable or disable the alarm.
However, now I'm trying to set and read a variable which stores a name value to indicate which vibration sensor was triggered and use that variable in a notification service node (Home Assistant).
I've tried multiple variations of code within a Function node and they all result in "undefined" when trying to read a Context Flow variable "vbSensor" in a debug node attached to the Function node.
The code I have in my function node currently is:
var sensor = flow.get("vbSensor"); msg.sensor = sensor; return msg;
I've attached screenshots of the flow and the output. I think I might be misunderstanding scope in some way or else not referencing the Context variable correctly in either the function or the debug node? It's strange though that the Switch node can successfully read the value of the "alarmActive" variable. When I try to read that value with the function node code, it also produces an "undefined" value. What am I doing wrong?