Node REd getting thermostat attributes

Hi:

I have my thermostat set at our normal house schedules. However sometimes our schedule changes and I want to set up an automation that will check if user is family is home. If family is home it will check the current preset mode attribute of the thermostat and if not set to “home” then call service to set up the thermostat to “home” preset mode. This will cover the thermostat to be at right temperate when our schedule changes.

I know that the attribute I want to check is on
entitiy: climate.home
attribute path: data.attributes.climate_mode

So far I know for sure if family home by this:

But where I struggle is how to access that attribute of the thermostat so when that value is set to sleep or work or away then I call a service to change it to “home”. I dont have an issue calling the service. that works well. It is just accessing the data from that attribute.

Tried with function nodes and switches but still struggling to know how to get it right.

If you want to change the preset on the thermostat, in a call service node.

1 Like

If you are trying to find the state (and its attributes) of an entity, use a ‘current state’ node. Put a debug node on the end showing the complete message, you will see the attributes you are try to check.

1 Like

Sorry I misread the question, this is an example for using attributes.

Thanks with all your suggestions I was able to figure out. I am going to post the solution just in case someone needs help.

  1. What I did first was to get a current node report the state of msg.data from the climate.home and output that to a debug note as suggested.

That gave me the idea that the data I was looking for was in msg.data.attributes.climate_mode. It was also in msg.data.attributes.preset_mode.

Then I attached the output from that node to a swtich Node.

The swtich is looking for one of two outputs a string from msg.data.attributes.present_mode

then I just have to call my service from the outputs. It works like a charm. Thanks so much for the pointers.

I hope that helps someone.

9 Likes

And you can actually do that without the switch node. In your current state node against the If State element set jsonata as the evaluation type then

$entity().attributes.preset_mode = "Home"

and it will send a message via the top output, otherwise via the bottom output.

1 Like

Your write up gave me a crash course on a few topics in HA. Thank you kindly for that AND the thread to help me get this flow working!

Sorry to reply directly to an answer you gave a while back.
As far as I understand, your answer allows the current state node to filter a single attribute of the home assistant entity, or compare it to a threshold value.
Would it be possible to simply set the payload or data to just the value of a single attribute?
For example, from the above example, assign the value of “current_temperature” to the payload, so that it can be stored in a flow variable or be used for comparing it to another value retrieved from another home assistant entity ?

Or do I need a function node for that??

Away from home so can’t check directly, but you should be able to set it to the payload or any other field directly from the current state node, there is a section for output properties at the bottom of the dialogue, or use a change node.

Ok, sorry,
I spoke too soon. I have found a way using your answer
Just add the
$entity().attributes.current_temperature

to msg.payload

Sorry to bother

Hi Roger,

Sorry again.
But I can use this “magic” directly in an “event state node” and (of course) I can use it in a function-node … but is there a way to use it in a change-node?

Can I use any data found in the payload coming from an events-node , as part of the new payload in a change-node?
What is the syntax there? I have tried to copy the “path” that i found in a debug node.

If I use $entity(), what does that specifically point to (if not the payload)
Isn’t using single or double curly brackets supposed to indicate referring to a variable?
In a change node, it gets an error unless I include it into " ", but then of course it simply adds the literal string
“{{$entity().attributes” just adds this literally into the payload going out of the node.

I have tried change msg.payload to “string” and “Jexpression”

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/call-service.html#targets

Is somewhat helpful in dealing with templates.

Hi,

I have a similar situation to this thread, but want to set the data attribute of the generic thermostat in Home assistant from a function node in node red, The attribite I want to set is temperature. It looks like this inside the entity

What the function node does is set the temperature based on a schedule of preset periods. This needs to change the temperature set point of the generic thermostat and hence turn on or turn off the heater.
I have looked at the following
global.set("homeassistant.homeAssistant.states['climate.central_heating'].attributes.temperature", temp);
but this is not right
Any ideas would be a greatly appreciated

worked it out.

basically used a call service node with the following
The temp variable is determined from my function node that sets the temp based on the period of the day (Mon -Fri, Sat, and Sun)

Thanks a lot for sharing this. I have been looking for a while and was unable to understand this - with your post this solves a part of my problem.

I wonder if you can guide on how can send a command to the thermostat? I have a nest thermostat and I would like it to start the boiler only if room temperature falls below a set point (usually it runs on a schedule and does not stop even if the room temperature is reached)

its me again. I would like to be able to extract the cold_tolerance and hot_tolerance atributes but cannnot find them. Any ideas? These are in the configuration.yaml under the climate config

Here is how I do it with a homekit connected ecobee and the hvac_action attribute.

[{"id":"858850f8.d94488","type":"tab","label":"ECOBEE","disabled":false,"info":""},{"id":"5b5b9e4378990062","type":"group","z":"858850f8.d94488","name":"HVAC - Return Air Booster On/Off","style":{"label":true,"stroke":"#000000","fill":"#e3f3d3","color":"#000000"},"nodes":["6f81d9184d2ba8ea","290a93436704232b","6aa89b12dde1fb54","d96505bee79ed87d","9afa4e5e4c6260b7","de16bbc0282104c6","21cea1d0f4205453","27cc7b22e27e5b4f","08432ba0f098e0d5"],"x":34,"y":39,"w":1052,"h":222},{"id":"6f81d9184d2ba8ea","type":"inject","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"Run Manually","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":220,"wires":[["290a93436704232b"]]},{"id":"290a93436704232b","type":"api-current-state","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"Ecobee Thermostat","server":"39dd3b2a.d5a744","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"climate.thermostat_temp_ecobee_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"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":270,"y":140,"wires":[["9afa4e5e4c6260b7","de16bbc0282104c6"]]},{"id":"6aa89b12dde1fb54","type":"switch","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"heating","vt":"str"},{"t":"eq","v":"cooling","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":730,"y":140,"wires":[["d96505bee79ed87d","27cc7b22e27e5b4f"],["d96505bee79ed87d","27cc7b22e27e5b4f"],["d96505bee79ed87d","08432ba0f098e0d5"]],"outputLabels":["heating","cooling","idle"]},{"id":"d96505bee79ed87d","type":"debug","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"hvac state?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":80,"wires":[]},{"id":"9afa4e5e4c6260b7","type":"change","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"hvac_action --> payload","rules":[{"t":"move","p":"data.attributes.hvac_action","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":140,"wires":[["6aa89b12dde1fb54"]]},{"id":"de16bbc0282104c6","type":"debug","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"ecobee attributes","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"data","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":80,"wires":[]},{"id":"21cea1d0f4205453","type":"server-state-changed","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"Ecobee Thermostat State","server":"39dd3b2a.d5a744","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"climate.thermostat_temp_ecobee_2","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"}],"x":170,"y":80,"wires":[["290a93436704232b"]]},{"id":"27cc7b22e27e5b4f","type":"api-call-service","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"ON - Return Booster","server":"39dd3b2a.d5a744","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":["43128e40993b123d0d8546b1302ccc5d"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":960,"y":140,"wires":[[]]},{"id":"08432ba0f098e0d5","type":"api-call-service","z":"858850f8.d94488","g":"5b5b9e4378990062","name":"OFF - Return Booster","server":"39dd3b2a.d5a744","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":["43128e40993b123d0d8546b1302ccc5d"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":960,"y":200,"wires":[[]]},{"id":"39dd3b2a.d5a744","type":"server","name":"Home Assistant","addon":true}]