Help using HA sensor states in the data field of a NodeRed 'action' node?

What’s the easiest/best way to access my Home Assistant sensor values (states) in NodeRed, specifically in the ‘action’ (‘call service’) node?

Situation: I’m building out my thermostat automations. I’ve created a handful of input_number helpers for each of my desired temperatures like input_number.hvac_away_cool = 78F and input_number.hvac_home_night_cool = 72F. I’m trying to create automations that set my thermostat to those values at set times/conditions, like “when nobody is home, set the low temp to input_number.hvac_away_heat and the high temp to input_number.hvac_away_cool” and “when its 10pm on a school night, set the AC to input_number.hvac_home_night_cool”. It would make my flows a lot cleaner/easier to read if I could reference HA states directly from the ‘action’ node data field.

For example, when the house goes empty, I’d like to be able to set an ‘action’ node calling climate.set_temperature with data expression:
{
“target_temp_high”: int(ha.input_number.hvac_away_cool),
“target_temp_low”: int(ha.input_number.hvac_away_heat)
}

I found a (apparently undocumented) method that uses a function node in the flow to set the msg’s data fields (see below), but that is annoying to have to build/include that function in every flow when it’d be much easier to just reference HA values directly. Other people have wanted to access HA sensor states in their NR nodes before, what’s the best way of doing it?

My current solution is to use a function node that loads the sensors I want into the msg object.
var hvac_away_cool = global.get(‘homeassistant.homeAssistant.states[“input_number.hvac_away_cool”].state’);
msg.hvac_away_cool = parseFloat(hvac_away_cool);

Data manipulation in nodered is primarily handled using jsonata. Take a look at the web socket nodes docs, there are many examples.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/jsonata/

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/cookbook/