Change multiple climate in a call service


Starting with node red, for some automation, i want to change temperature of multiple climate devices in one “call service”. I found to set the same temperature to many climate, but not a way to send different temperature to different climate in one sigle call

Is it a way to do it ?

I tried this JSON as data for call service (with Domain: climate and service: set_temperature):

         "entity_id": "climate.thermostat_tristan",
         "temperature": 19
         "entity_id": "climate.thermostat_tamia",
         "temperature": 18

but I got :

"Call-service API error. Error Message: must contain at least one of temperature, target_temp_high, target_temp_low."

What Am I doing bad ?



(beginner of the day in node-red :wink: )

The question probably is: Why do you want to do all that in one single call?
Just for cosmetic reasons?

Afaik it gets very complicated but should be achievable by using a function node and sending the calls seperate. However, in the end you will always do multiple seperate calls to the set_temperature.
This is because the set_temperature service call itself does not support several entities with different temperature values.

Basically you can inject any data via the function node:

newmsg.payload = { data: {  "entity_id": "climate.thermostat_tristan", "temperature": 19 } }

On top, with separate calls in the NodeRed Flow you can save some time later when you try to debug the flow or trying to figure out what you were doing in the first place.
So I would recommend to simply just do seperate calls and simplify the automation at a different place.

Thanks for your answer.

I just want to have something readable. Putting a ‘call function’ node for every of my climate (14 zones) for my 4 ‘heating modes’, means 52 nodes in the flow. I was just expecting a more ‘optimized’ way to achieve this.

Maybe a subflow to which I pass a ‘matrix’ with the value for each room ? (Again, I am new in node-red, and ‘low/No-code’ programming… I try to get a good approach)

Well, you actually only need one single call service node. You can dynamically address the data field as mentioned before either via Mustache Templates:
or simply by using a function node as described above.

Maybe its worth to think about separating the flows. I would probably try to make one generic flow that can address all of the 14 Zones individually. And then for the heat modes, basically just refer to that original flow and change to values?

Are you really setting different temperatures in all 14 zones??
I have 19 thermostats in my house.
As an example, in my goodnight routine I set all of the basement thermostats to 1 temperature, the upstairs living area to another, and the bedrooms to another again. So I really only have 3 nodes doing all 19 thermostats because I can take the 4 bedroom thermostats that are all being set to 20 degrees and put them in the same node.

One thing I’ve learned about node-red, it’s certainly possible to clean it up and reduce those nodes. But 1.5 years from now when you need to adjust something, you’re sitting there staring at your flow trying to remember what you did instead of just grabbing that node and making the change you need.

Thank for all your answers. I have no better view of the possibilities and usage of it.
I will try some config to see what fit the best my needs.

A very belated thank you. I just installed NodeRed this morning and it’s been a learning curve! I also wanted to change the temp of multiple climate entities and your original code got me there.

I’m grabbing a list of entities from a ‘get entities’ node and passing it to this ‘call service’ node

The data part works OK like this:

{ "entity_id": $join(payload.entity_id, ",") ,"temperature": 20 }

The whole flow looks like this:

[{"id":"96cc0ef1a09836dd","type":"ha-get-entities","z":"76a62a4aed5d1e79","name":"Climate entities","server":"8a1c9961.cf2828","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"climate.","valueType":"str"},{"property":"entity_id","logic":"is","value":"^climate\\.(?!tesla)","valueType":"re"},{"property":"entity_id","logic":"is","value":"^climate\\.(?!trv)","valueType":"re"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":400,"y":400,"wires":[["09cc68be54e1b1a4"]]},{"id":"09cc68be54e1b1a4","type":"api-call-service","z":"76a62a4aed5d1e79","name":"Climate Heat Actuators Max temp","server":"8a1c9961.cf2828","version":5,"debugenabled":true,"domain":"climate","service":"set_temperature","areaId":[],"deviceId":[],"entityId":[],"data":"{ \"entity_id\": $join(payload.entity_id, \",\") ,\"temperature\": 26 }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":680,"y":400,"wires":[[]]},{"id":"2191d7f7be755c8a","type":"ha-button","z":"76a62a4aed5d1e79","name":"Heat Actuators Max temp","version":0,"debugenabled":false,"outputs":1,"entityConfig":"acc17c38eadebc3b","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":190,"y":400,"wires":[["96cc0ef1a09836dd"]]},{"id":"8a1c9961.cf2828","type":"server","name":"Home Assistant","addon":true},{"id":"acc17c38eadebc3b","type":"ha-entity-config","server":"8a1c9961.cf2828","deviceConfig":"","name":"Heat actuators Max temp","version":"6","entityType":"button","haConfig":[{"property":"name","value":"Heat actuators Max temp"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false}]

Hope that helps someone sometime!