Trying to set msg.payload.target_temperature_c

This is clearly a problem with my understanding, but I'm stumped!

I'm basically following the example in this node red documentation page, bottom of the section "Changing message properties", except I'm injecting a numerical value.

I am using a change node to 'copy' a value (i.e. msg.payload, received from an inject node) to msg.payload.target_temperature_c. However when I attach a debug node to output, it just shows the value I injected in msg.payload of the output, not in msg.payload.target_temperature_c.

End result: I want to be able to update my Nest thermostat with a value from a slider on dashboard... but this is the bit that's failing.

Here's my node. When I hit the inject button, I am hoping to see msg.payload.target_temperature_c as the value 19. (But I'm not)


I'm no expert here.
But the following observations might help.

After the inject node, msg.payload is a string.

In the change node, you act if msg.payload is an object. This seems to fail.

In my local test installation, I expanded your change node the following way:

  1. set msg.tmp to msg.payload
  2. delete msg.payload
  3. set msg.payload.target_whatever to msg.tmp

This did the trick. But it might not be the most efficient solution. Let's see what the more knowledgeable forum members have to say.

Kind regards,



Modify the Change node so that it Moves msg.payload To msg.payload.target_temperatue_c and it will work.

1 Like

That is correct - strings cannot have properties. JavaScript will let you set them but it will fail silently.

Rather than copy, you can configure the Change node to move msg.payload to msg.payload.target_temperature_c and it will work.

1 Like

Thanks all, that helped my understanding.

Aside: how can I post my node code here on this forum to display on a single line, as was done by @Colin?

you need to
start with three backtic's,
then on the next line put your flow,
then on the next line three more backtic's

1 Like

@zenofmud Many thanks!

In addition, if you want it to just take one line then when you export choose Compact down at the bottom right of the export window.