Parse thermostat args

I have a node red node Nora" which reads temperature values from my room via Google Home .
I have parsed values for heat/eco/off so i can forward calls to rest api's via voice commands. Ok.
Is there any way i can read temperature values and parse them into a rest api, i believe the term is "float" ?
Here is a pic of my setup.

Here is debug over Nora (Thermostat id 123)

I have inserted json node - split and switch to seperate payloads.


After switch i have a switchstring node that has "args" to parse to my rest api (Fibaro Nodes)
(this is pic of "mode" heat/eco/off payload and args for rest api)

Is there a way to parse temperature values from another payload
"setpoint" to my rest api nodes ?

Hopefully with voice commands on Google Home i can adjust temperature with rest api calls back to my home Center.

Excuse my newbie terminology, i have only recently begun with node red and iot in general.

Any ideas or info would be greatly appreciated.

Your switch node is looking for ‘msg.topic’ while the values come from ‘msg.payload’
But yes, msg.topic is a way to differentiate between devices.

Can you post your flow?

Thanks bakman2
What is the best way to send my flow , can copy to clipboard then ??

flows.json (4.0 KB)

Select the nodes and export clipboard via the hamburger menu and use the code icon here in the editor and paste.

Your attachment will work too

ok , see my previous attachment

I am not entirely sure what data your first produces.

Try this example, you can connect all the destination thermostats to the function node.
The key is the topic.

[{"id":"3111dd0b.5de7d2","type":"debug","z":"c1c29249.fdc28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":490,"y":792,"wires":[]},{"id":"84a5685.8846498","type":"function","z":"c1c29249.fdc28","name":"","func":"p = msg.payload\nt = msg.topic\nm = p.mode\n\n\nif(m ==\"off\"){\n    return {topic:t,payload:{name:\"setMode\",args:[0]}}\n}\nif(m ==\"heat\"){\n    return {topic:t,payload:{name:\"setMode\",args:[1]}}\n}\nif(m ==\"eco\"){\n    return {topic:t,payload:{name:\"setMode\",args:[11]}}\n}\n","outputs":1,"noerr":0,"x":336,"y":792,"wires":[["3111dd0b.5de7d2"]]},{"id":"51d8b11a.5bb208","type":"inject","z":"c1c29249.fdc28","name":"mode off","topic":"Thermostat/id/123","payload":"{\"mode\":\"off\",\"setpoint\":20,\"setpointLow\":20, \"setpointHigh\":30}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":770,"wires":[["84a5685.8846498"]]},{"id":"744c34f1.90bb24","type":"inject","z":"c1c29249.fdc28","name":"heat","topic":"Thermostat/id/123","payload":"{\"mode\":\"heat\",\"setpoint\":20,\"setpointLow\":20, \"setpointHigh\":30}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":814,"wires":[["84a5685.8846498"]]}]

Perhaps you can explain step by step what your flow should do.

Thanks for reply,

  1. Nora node (Thermostat id123) gets voice commands from Google Home mini.
  2. Nora node har 4 payload outputs
    a. mode: heat/eco/off
    b. setpoint
    c. setpointLow
  3. I want to use mode and setpoint only
  4. Parse payloads from Nora node and put them into my Hc2 nodes (which send rest api calls to fibaro).
  5. My Hc2 nodes are
    a. id123 (mode)
    b. id 123 (setpoint)
    Thanking you for your time.

Update , have been playing with this a while, have thermo mode working , but not setpoint for temperature. Been reading about targetlevel and rest api but can't find a node and don't know how to code. Thought i might send a pic at least to explain a little.
Really appreciate any help

Did you look at my example ? Copy and import it in node-red.

Hei bakman2, thanks for reply. I understand the idea of the function but not sure how this will help set temp values ?? Imported and see that your flow has very same output as nora node.
Temperature args via rest api to fibaro are with ,POST
{"name":"setTargetLevel","args":[21]} ----- http://HCip/api/devices/123/action/setTargetLevel.. where changing args value increases or decreases temp in thermostat. The idea is to read values direcly from Nora node and parse on to rest api call , auto inject , so to speak..
The only thing i can think of is a function node that can align/pair values in a table ? from number in 4.0 celcius to 24.9 celsius with args [4.0] to [24.9] .
Or is there another method to read from Nora and split to 1. mode - 2. temp ?
Anyway, i greatly appreciate all help, been working with this for hours, interesting but i have met a brick wall with parsing temp values......:frowning:

The only thing i can think of is a function node that can align/pair values in a table ? from number in 4.0 celcius to 24.9 celsius with args [4.0] to [24.9] .

What do you mean by this ?

You have posted many different things:

and now
is added.

Correct me if I am wrong:

input node produces:

You only need mode and setpoint and you want to send this to fibaro nodes, correct ?

Nora node output;

setpoint: 22 -- trying to "convert this number to an "arg" for example {"name":"setTargetLevel","args":[22]} .
(setpoint reads values 4.0 -4.1- 4.2 etc up to 24.999 celsius).

so i can send rest api

i was, was trying with new rest api request
http://HC2 ip/api/devices/621/action/setTargetLevel
http://HC2 ip/api/devices/621/action/setThermostatSetpoint
have the same function.

correct , only mode and setpoint.

But isn't the point of the fibaro nodes that you don't have to use the api, but just the fibaro nodes ?


[{"id":"cd598f71.ca4588","type":"inject","z":"2359d92f.6bbf46","name":"setpoint","topic":"","payload":"{\"mode\":\"off\",\"setpoint\":22,\"setpointLow\":20,\"setpointHigh\":30}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":176,"y":462,"wires":[["6c807c6e.bf8314","a1664924.18a648"]]},{"id":"b808551.cd31fa8","type":"debug","z":"2359d92f.6bbf46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":488,"y":462,"wires":[]},{"id":"6c807c6e.bf8314","type":"function","z":"2359d92f.6bbf46","name":"","func":"m = msg.payload\ns = m.setpoint\nreturn {payload:{name:\"setTargetLevel\",args:[s]}}","outputs":1,"noerr":0,"x":336,"y":462,"wires":[["b808551.cd31fa8"]]},{"id":"a1664924.18a648","type":"debug","z":"2359d92f.6bbf46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":356,"y":506,"wires":[]}]

I assumed that the fibaro device nodes were rest api's ?
Completely wrong ???

Correct, so you don't have to call https://HC2xxxx

Just to thank you bakman2 for all of your help, it works at last.
Your info on function etc set me in the right direction.
Appreciated :slight_smile: