Increase / Decrease value of an entity attribute for climate control

Hi,

I try to set up my climate automation using the better thermostat integration. This integration gives me the following entity:

On my Dashboard I have two controls for up and down (blue and red button) which are input_numbers created as a helper.

IMAGE-1

I am looking for a way in Node Red to increase / decrease the “temperature” attribute of the entity by 0,5°C with each click on a button.

I hope you can help me.

Thanks.

In the settings of the input number there is a step size value. This is how much the number will increase/decrease. You can use a call service to either increment or decrement the number.

image

I know, but I need to increase / decrease a climate entity which does provide increment / decrement.

So my other idea was to increment / decrement another “temperature helper” which I then set equal to the climate entity via set temperature = temperature helper. I assume this works with a function node but I couldn’t figure out how.

Any ideas?

[{"id":"d12383266f4acd53","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"3eb915ca927bc26f","type":"comment","z":"d12383266f4acd53","name":"Buttons on thr Dashboard","info":"","x":230,"y":80,"wires":[]},{"id":"7ad5c67481682e83","type":"server-state-changed","z":"d12383266f4acd53","name":"Target Temperature up Button","server":"d6e1a14d.333e1","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.wohnzimmer_soll_temperatur_hoch","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":240,"y":140,"wires":[["042192b2613f79e4"]]},{"id":"df3307d973de5dd9","type":"server-state-changed","z":"d12383266f4acd53","name":"Target Temperature down Button","server":"d6e1a14d.333e1","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.wohnzimmer_soll_temperatur_runter","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":250,"y":200,"wires":[["087563227277d3e3"]]},{"id":"042192b2613f79e4","type":"api-call-service","z":"d12383266f4acd53","name":"Increase Target Temperature by 0,5°C","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"climate","service":"","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":610,"y":140,"wires":[[]]},{"id":"087563227277d3e3","type":"api-call-service","z":"d12383266f4acd53","name":"Decrease Target Temperature by 0,5°C","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"climate","service":"","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":610,"y":200,"wires":[[]]},{"id":"9b837506e3b121ed","type":"comment","z":"d12383266f4acd53","name":"Target Temperature in the Room","info":"","x":590,"y":80,"wires":[]},{"id":"e50d05dd72367863","type":"api-call-service","z":"d12383266f4acd53","name":"Increase Target Temperature Helper by 0,5°C","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"input_number","service":"increment","areaId":[],"deviceId":[],"entityId":["input_number.wohnzimmer_soll_temperatur"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":630,"y":440,"wires":[[]]},{"id":"df617a51613c7ad7","type":"api-call-service","z":"d12383266f4acd53","name":"Decrease Target Temperature Helper by 0,5°C","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"input_number","service":"decrement","areaId":[],"deviceId":[],"entityId":["input_number.wohnzimmer_soll_temperatur"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":500,"wires":[[]]},{"id":"7c62239d42ae252a","type":"server-state-changed","z":"d12383266f4acd53","name":"Change in Target Temperature Helper","server":"d6e1a14d.333e1","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_number.wohnzimmer_soll_temperatur","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":270,"y":580,"wires":[["a14bd58eec44b085"]]},{"id":"1fe3d798ba32c812","type":"server-state-changed","z":"d12383266f4acd53","name":"Target Temperature up Button","server":"d6e1a14d.333e1","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.wohnzimmer_soll_temperatur_hoch","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":240,"y":440,"wires":[["e50d05dd72367863"]]},{"id":"27e9cef7d6541867","type":"server-state-changed","z":"d12383266f4acd53","name":"Target Temperature down Button","server":"d6e1a14d.333e1","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.wohnzimmer_soll_temperatur_runter","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":250,"y":500,"wires":[["df617a51613c7ad7"]]},{"id":"a14bd58eec44b085","type":"function","z":"d12383266f4acd53","name":"function 6","func":"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":580,"wires":[["a6c53450d19fc6ba"]]},{"id":"a6c53450d19fc6ba","type":"api-call-service","z":"d12383266f4acd53","name":"Climate Entity set Temperature from Temperature Helper","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"climate","service":"set_temperature","areaId":[],"deviceId":[],"entityId":["climate.wohnzimmer"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":580,"wires":[[]]},{"id":"d6e1a14d.333e1","type":"server","name":"Home Assistant","addon":true}]

I think I am pretty close now. The only thing I don’t get to work is to set the target temperature using msg.payload in the last step. The debug node gives me the target temperature of the helper and I need to use this message as the target temperature of the climate entity.

Bildschirmfoto 2024-07-31 um 10.28.06

[{"id":"fa239ed46f486012","type":"comment","z":"2447a8dbe0e6dfa1","name":"Soll Temperatur Einstellung","info":"","x":170,"y":1220,"wires":[]},{"id":"66af177e43a225e7","type":"server-state-changed","z":"2447a8dbe0e6dfa1","name":"Soll Temperatur hoch Button","server":"d6e1a14d.333e1","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.wohnzimmer_soll_temperatur_hoch","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":1280,"wires":[["2d13cd3c87867916"]]},{"id":"2d13cd3c87867916","type":"api-call-service","z":"2447a8dbe0e6dfa1","name":"Soll Temperatur Helfer 0,5°C hoch","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"input_number","service":"increment","areaId":[],"deviceId":[],"entityId":["input_number.wohnzimmer_soll_temperatur"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":500,"y":1280,"wires":[["2db00c8c443343ed"]]},{"id":"f58bbe5988ccab66","type":"server-state-changed","z":"2447a8dbe0e6dfa1","name":"Soll Temperatur runter Button","server":"d6e1a14d.333e1","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.wohnzimmer_soll_temperatur_runter","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":1340,"wires":[["77209d9b24663ab5"]]},{"id":"77209d9b24663ab5","type":"api-call-service","z":"2447a8dbe0e6dfa1","name":"Soll Temperatur Helfer 0,5°C runter","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"input_number","service":"decrement","areaId":[],"deviceId":[],"entityId":["input_number.wohnzimmer_soll_temperatur"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":500,"y":1340,"wires":[["2db00c8c443343ed"]]},{"id":"d18a0d706ae7ee72","type":"api-call-service","z":"2447a8dbe0e6dfa1","name":"Soll Temperatur = Soll Temperatur Helfer","server":"d6e1a14d.333e1","version":5,"debugenabled":false,"domain":"climate","service":"set_temperature","areaId":[],"deviceId":[],"entityId":[],"data":"{\"temperature\":msg.payload}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1180,"y":1300,"wires":[[]]},{"id":"430a03bbfaace6b4","type":"debug","z":"2447a8dbe0e6dfa1","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1080,"y":1360,"wires":[]},{"id":"2db00c8c443343ed","type":"api-current-state","z":"2447a8dbe0e6dfa1","name":"Soll Temperatur Helfer?","server":"d6e1a14d.333e1","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.wohnzimmer_soll_temperatur","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":830,"y":1300,"wires":[["430a03bbfaace6b4","d18a0d706ae7ee72"]]},{"id":"d6e1a14d.333e1","type":"server","name":"Home Assistant","addon":true}]

When a number has quotes, it’s a string. To use it for climate it needs to be in the form of a number. Inside the HA nodes the prefix msg is not required nor recommended. So you would use "temperature": $number(payload) to convert from a string to a number.

1 Like

It works :muscle:. Thank you :blush:.

1 Like