Hello,
I’m having a little trouble trying to incorporate a variable into a Node Red service call.
I’ll explain what I’m trying to accomplish in case there’s a better way to go about it.
I’m using a combination of Node Red and Home Assistant automations to control my heating system via 2 wall thermostats which control my boiler and several TRVs
When I leave the house, my TRV temperate targets are changed depending on the status of a switch that tells the system whether or not my dog is at home.
If the dog is home, all the other TRVs are set to a lower temperature while the TRV in the man cave is set to a higher temperature (this is what I need to be a variable)
The wall thermostat for the bedrooms is then set to a high or low temperature based on a stand alone climate sensor in the man cave. If the temperature goes below 17.5 degrees, the wall thermostat gets set to 25. Once the man cave hits 19 degrees, the wall thermostat gets set to 10 degrees. When I come home, the other TRVs are set to the high setting again (ie I will have multiple different entities being set to that temperature)
The TRV temp settings are currently changed by automations, while the auto heating for the dog is currently being controlled via Node Red. Node Red also has some flows to switch the thermostats for upstairs and downstairs to a higher temperature to turn the heating on for an hour by pressing a button.
I’m using one of these flows to experiment with using a variable in the temperature service call going to the thermostat.
The reason for this is that I’ve been doing a little tweaking to try to find the best values. Because I’m using a standalone climate sensor in the middle of the room rather than the TRV, if the TRV setting is too low and it’s too cold outside, the TRV closes before the temperature of the room rises enough to trigger the thermostat back to the low setting. But a few days ago the node red flow failed so the heating was on all day and the poor dog drank his full bowl of water and pissed on my sofa. Because the man cave is the only radiator that is on during the day bar the hallway which is a dumb valve and set very low, and the two bathrooms which don’t have thermostatic valves at all, the boiler ran all day.
I’ve tweaked enough with the temperatures in the past that I’d rather just be able to set a couple of variables and use those to set the temperatures in the service calls.
I’ve also thought of using automations then just having node red press a button to set the thermostat but I can’t see any way to use a variable in a temperature service call in an automation either.
I’ve set 2 environment variables in the Node Red settings (temphigh and templow) and tested a little using the least critical flow that boosts the downstairs heating for an hour.
I’ve used various combinations of global.temphigh $env{temphigh} $env(‘temphigh’) but I can’t seem to get the temperature to change with anything except a plain number in the service call.
I’ll include the nodes here. The heating off flow is currently just using the standard temperature of 10 degrees while the heating boost is where I’m trying to put the variable in the service call.
[
{
"id": "8d25853ae6b0d0f3",
"type": "tab",
"label": "test heating flow",
"disabled": false,
"info": "",
"env": []
},
{
"id": "11fb445d05b1ae26",
"type": "api-call-service",
"z": "8d25853ae6b0d0f3",
"d": true,
"name": "",
"server": "f0314f01c7348223",
"version": 5,
"debugenabled": true,
"domain": "climate",
"service": "set_temperature",
"areaId": [],
"deviceId": [],
"entityId": [
"climate.living_room_thermostat"
],
"data": "{\t \"temperature\": \"{{global.temphigh}}\"\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "1",
"propertyType": "msg",
"value": "",
"valueType": "data"
},
{
"property": "1",
"propertyType": "flow",
"value": "",
"valueType": "data"
},
{
"property": "1",
"propertyType": "global",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"x": 450,
"y": 200,
"wires": [
[
"29bc0dda9bc73364"
]
]
},
{
"id": "3d0167ac4d552d88",
"type": "api-call-service",
"z": "8d25853ae6b0d0f3",
"d": true,
"name": "",
"server": "f0314f01c7348223",
"version": 5,
"debugenabled": true,
"domain": "climate",
"service": "set_temperature",
"areaId": [],
"deviceId": [],
"entityId": [
"climate.living_room_thermostat"
],
"data": "{\"temperature\":10}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 550,
"y": 400,
"wires": [
[]
]
},
{
"id": "8abaed45023ced42",
"type": "ha-button",
"z": "8d25853ae6b0d0f3",
"d": true,
"name": "Downstairs Heating 1 Hour Boost",
"version": 0,
"debugenabled": false,
"outputs": 1,
"entityConfig": "ae607660d1d070be",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"x": 150,
"y": 260,
"wires": [
[
"11fb445d05b1ae26"
]
]
},
{
"id": "4e7bd4937e817ec1",
"type": "ha-button",
"z": "8d25853ae6b0d0f3",
"d": true,
"name": "Downstairs Heating Off",
"version": 0,
"debugenabled": false,
"outputs": 1,
"entityConfig": "f12d701cc47d62eb",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"x": 260,
"y": 380,
"wires": [
[
"3d0167ac4d552d88"
]
]
},
{
"id": "29bc0dda9bc73364",
"type": "trigger",
"z": "8d25853ae6b0d0f3",
"d": true,
"name": "",
"op1": "",
"op2": "",
"op1type": "nul",
"op2type": "pay",
"duration": "60",
"extend": false,
"overrideDelay": false,
"units": "min",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 710,
"y": 140,
"wires": [
[
"3d0167ac4d552d88"
]
]
},
{
"id": "f0314f01c7348223",
"type": "server",
"name": "Home Assistant",
"version": 2,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": true,
"heartbeatInterval": "30"
},
{
"id": "ae607660d1d070be",
"type": "ha-entity-config",
"server": "f0314f01c7348223",
"name": "Downstairs Heating 1 Hour Boost",
"version": 2,
"haConfig": [
{
"property": "name",
"value": "Downstairs Heating 1 Hour Boost"
},
{
"property": "icon",
"value": ""
},
{
"property": "device_class",
"value": ""
}
],
"entityType": "button"
},
{
"id": "f12d701cc47d62eb",
"type": "ha-entity-config",
"server": "f0314f01c7348223",
"name": "Downstairs Heating Off",
"version": 2,
"haConfig": [
{
"property": "name",
"value": "Downstairs Heating Off"
},
{
"property": "icon",
"value": ""
},
{
"property": "device_class",
"value": ""
}
],
"entityType": "button"
}
]