Unable to get temperature data from climate home assistant

I have a thermostat automation in Home Assistant that triggers when the thermostat is set above a certain temp. I cannot figure out how to read this value in Node Red. I have tried both polling and state change, but both of them will only return the value of "heat" or "cool" that the thermostat is in, not the temperature (states.climate.thermostat.attributes.temperature). If I set the state type as number I only get the output of NaN. How do I test the actual temperature? I'm pretty excited about using Node Red but so far it has seemed much simpler to just code the yaml and use standard automations through HA. There seems to be a scarcity of specific and in-depth tutorials for Node Red. I can create a simple time based trigger flow (and find tutorials on doing so) quite easily, but more complex and detailed explanations do not seem to be available.

Hi and welcome to the forum.

The information is all there but because there is MUCH more freedom & far more possibilities, it is not really feasible to document everything (you wouldnt see the wood for the trees)

What is well documented is the building blocks and how tos.

It is best to learn how to get what you want out of node-red

I typically direct new users to this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

The cookbook is another good source

I was there something like a year ago...
The difference is that I never really considered yaml as being simple :slight_smile:
My reason to switch to nodered was my total inability to debug HA automations. At least with NR, debug is at a node reach.

As Steve pointed out, there are good examples in the cookbook and other places. And there is also the (very friendly) community! If you describe what is your problem, then without a doubt someone will give you the answer or will point you into the right direction.

In your case, if out of the "events state" change node, put a debug node with the entire msg. On the side you will see the full result and you will be able to pick the attribute you are looking for.
It should be something like msg.data.attributes.temperature and then up to you :wink:

Have a look at this video, skip through to 6:15

Well, your idea made sense, but no matter what I try I cannot extract the temperature state from the event. Non of the videos nor the cookbook go anywhere near into this depth. I'll keep trying and hoping someone knows how to accomplish this.

OK...more tinkering. I am able to send the temperature through a customs message using the trigger: state node. Now my problem is how to use that value. For example: if the temperature is > 69, set the thermostat to 69, otherwise take no action.

I was refering you your comment about "There seems to be a scarcity of specific and in-depth tutorials for Node Red" - There is lots of info.

Testing a value / changing a value / routeing a message are all covered in the videos and documentation.
In particular...

Putting these 3 concepts together, you can use the debug side-bar to get the path to the temperature then a switch node to test the value & route a message to change node where you change the temperature (or route to another path i.e. no where).


Part of the reason there is no in-depth or direct help for your particular problem is just that - it is your unique problem. node-red is infinitely flexible so unfortunately you have to learn the core concepts. Not that they are difficult, you just need to keep plugging away & re-watch that playlist a couple of times (trust me it is worth it).

Lastly, the reason you are getting generic help is two fold...

  1. You have provided no screenshots or flow export for people to examine and offer help on
  2. Your original issue was with a value you are getting from HA (this is the node-red forum - there are not that many HA users or threads here).

First of all, thank you for your responses. Though none of the videos or links are particularly helpful, I glean something from each of them. Part of my problem is I haven't been sure what I even need to ask.. I'm able to be quite specific now (I hope).

I am sending a custom message from the trigger: state node. In the debug window I am seeing msg: [ object, null, 62 ], but only when I have "Show Debug Information" checked. The only message I am able to see (which shows with that option checked or unchecked) is climate.thermostat: msg: Object { topic: "climate.thermostat", payload: "heat", data: object, _msgid: "xxxxx" }
I cannot determine how to get the 62 value out of the message. The switch node is definitely useful, but testing msg.payload[2] returns "a" (as that is the third letter of "heat"). How do I access the value in the custom message?

Can you do a screen snippet of the debug output (expand all properties before screenshotting)

Ensure debug node is set to show complete message
image

Also, can you copy the actual debug output using the debug copy button and paste it in a reply (correctly formatted so the forum doesn't screw it up)
9odQk9hmok

```
paste copied value/code between three backticks like this
```

[{"topic":"climate.upstairs","payload":"heat","data":{"event_type":"state_changed","entity_id":"climate.upstairs","event":{"entity_id":"climate.upstairs","old_state":{"entity_id":"climate.upstairs","state":"heat","attributes":{"hvac_modes":["off","heat_cool","cool","heat"],"min_temp":40,"max_temp":75,"fan_modes":["on","auto","diffuse"],"preset_modes":["none","away"],"current_temperature":69,"temperature":70,"target_temp_high":null,"target_temp_low":null,"current_humidity":33,"fan_mode":"auto","hvac_action":"heating","preset_mode":null,"fan_action":"running","dr_phase":-1,"friendly_name":"UPSTAIRS","supported_features":27},"last_changed":"2020-12-26T19:04:32.902571+00:00","last_updated":"2021-01-03T21:12:51.239805+00:00","context":{"id":"316d92ce088a2f81a87f37ac2809845f","parent_id":null,"user_id":null},"original_state":"heat"},"new_state":{"entity_id":"climate.upstairs","state":"heat","attributes":{"hvac_modes":["off","heat_cool","cool","heat"],"min_temp":40,"max_temp":75,"fan_modes":["on","auto","diffuse"],"preset_modes":["none","away"],"current_temperature":69,"temperature":62,"target_temp_high":null,"target_temp_low":null,"current_humidity":33,"fan_mode":"auto","hvac_action":"idle","preset_mode":null,"fan_action":"idle","dr_phase":-1,"friendly_name":"UPSTAIRS","supported_features":27},"last_changed":"2020-12-26T19:04:32.902571+00:00","last_updated":"2021-01-03T21:15:00.334381+00:00","context":{"id":"24681696b4aacd62502eaabfa2c7638a","parent_id":null,"user_id":null},"original_state":"heat","timeSinceChangedMs":699027458}},"origin":"LOCAL","time_fired":"2021-01-03T21:15:00.334381+00:00","context":{"id":"24681696b4aacd62502eaabfa2c7638a","parent_id":null,"user_id":null}},"_msgid":"c5d17a8a.daae28"},null,62]

ok, so the value is an object - thats good.


so you said....

and

If you watch the video and read the text in the link I posted earlier...

you will learn you can get the correct path by using the "copy path" button. Then you can paste that path into the change node to move it into payload. You could then send that to a switch node to check if the value is > 69 then into a change node again to set the value if > 69.

Trying that now. Looks promising.

there are two(actually three) buttons there side by side - one is copy path and the other is copy value... I'm guessing you hit the wrong one by mistake

That did it! Thanks so much for your help. I will continue reading and learning. I still think there are some ways that just straight coding yaml is easier, but I expect this to be more robust in the end.

1 Like