Setting an input_number value from a sensor

Hi,
I’m very new to Node-RED, so this should probably be categorised as a noob question…But, here goes.

I have a flow that consists of the following

  • A events:state node, that reads an input_boolean and is connected to a…
  • Switch node, that has 2 outputs, “on” and “off” (based on the input_boolean). “On” is connected to a…
  • “call service” node. This node sets another HA entity (an input_number) to a fixed value, “18”. I’ve entered the following
{
    "value": "18"
}

in the “data” field (I guess you can call this a payload".

So, when the state node is set to “on”, the input_number is set to 18. I have tested the flow, and it works.

But, how can I replace the static value (“18”) with yet another value from HA, in this case, a sensor? I’ve tried “everything”, but can’t get my head around how this works.

I.e., i want to replace the JSON above with

{
    "value": [states.sensor.xxx]
}

(The problem that I want to solve is the following: When I enable “vacation mode” in HA, I want to set my heat pump to a preconfigured value. I know that this could be done with a basic HA automation, but this is going to be a more complex flow later on, I’m just trying to understand the basics now).

Set the data section to J;expression not json and use

{"value":$number($entities("input_number.pressure_loop_interval").state)}
3 Likes

Ah, that makes sense. Worked great, thanks!