Deactivate Heating while window is open

Hello Guys,
this is a beginner question for a node-red beginner as I am :slight_smile:
What I'm trying to archieve is a flow in which my radiators turning down as the window get's opened. So I'm filtering my DeConz events on that binary window sensor. If the status changes, the flow gets the current state of the heating vave / the temperature setting of it. This is here in the message object:

data.attributes.temperature

So I thought I need a function node which reads this setting, stores it and then reduces the setting to e.g. 12°C. And if the window gets closed again, it restores the previous setting. So I think the scope of my variable has to be flow-wide.

I started to write the following function:

var tempsetprev=data.attributes.temperature; //Hole aktuell eingestellte Temperatur
flow.set('tempsetprev',temsetprev);
msg.payload = tempsetprev;
return msg;

But I get: "ReferenceError: data is not defined (line 1, col 17)"
Can you help me where I'm wrong?

Regards

Add a debug set to show complete message and show us what the message really is.

data comes from where? Are you sure that is what is being passed to the function? Rather than the standard message object?

this is the data, coming from the current state node:

msg : Object
object
_msgid: "bcf5b49.6d22348"
payload: "unknown"
topic: ""
data: object
entity_id: "climate.danfoss_devolo_home_control_radiator_thermostat_heating_1"
state: "unknown"
attributes: object
hvac_modes: array[0]
min_temp: 7
max_temp: 35
current_temperature: 21.6
temperature: 20
node_id: 6
value_index: 1
value_instance: 1
value_id: "72057594143883282"
friendly_name: "Heizungsventil Bad"
supported_features: 1
last_changed: "2020-10-10T13:26:13.097704+00:00"
last_updated: "2020-10-11T13:43:54.738486+00:00"
context: object
timeSinceChangedMs: 91665546

next to this I added the function node.

Hi, you missed the msg. of the beginning

msg.data.attributes.temperature

When you copy the path it does not add the msg starting object.

2 Likes

thank you, that takes me one step forward :slight_smile: