Closed xHUNx closed 1 year ago
Hi @xHUNx,
Thanks for opening a new issue. Apologies that you're having these issues. I agree that the README could be clearer - the issue I think is that you're setting the msg.payload
property rather than msg.power
- I'll push a fix to the README, and I've attached an image that hopefully demonstrates what I'm trying to explain. Thanks
I've added the following to the README, hopefully this adds the required clarity. Please advise if you think rephrasing would help.
Please note: These properties must be present on msg
, not msg.payload
. e.g. msg.power
Thanks for the update, It is clear and I can confirm it's working,
However I would like to comment on your architecture (I'm no programmer myself so don't get me wrong I very much appreciate your work); I'm into home automation mainly MQTT based and with your approach I need to "inject" multiple items for each property override/overlay: Meaning [msg.power = ON, msg.temperature = 22 etc..] rather then adding all this into a single msg.payload like it's usually the case with other MQTT devices.
Is there a reason it's built that way?
My problem is that (might sound silly) I'm using [http in & http response ] to control and expose my node-red as Web API for my custom website, usually it's a GET/PUT API with the JSON Body that handled in Node Red as msg.payload example: { "zoneid": 2, "power":"on", "temperature": 22 }
Now in this case I won't be able to use a single message payload to control Tado but have to compose/convert it to multi item msg in order to work. Do you perhaps have an advise for that ?
Thanks again for your quick help and response.
Hi, the design decision was made quite a long time ago based on some other (probably anti-pattern) nodes - since then I've realised that, as you say, most other nodes use msg.payload
for their content. I haven't switched to using msg.payload.power
to preserve backward compatibility.
In nodered there is nothing particularly special however about msg.payload
(other than it being the default) and you can treat the whole of msg
as a JSON blob.
For your example you should be able to take your msg.payload
from your HTTP in/response and remap it to msg
using a function node, as below. Hope this helps.
This may demonstrate better
[{"id":"9425c1fec520a32f","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"5942f83f90b418ed","type":"inject","z":"9425c1fec520a32f","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"power\":\"on\"}","payloadType":"json","x":530,"y":160,"wires":[["e7cb91c2f19d45cf","a4eb5536cce56772"]]},{"id":"a4eb5536cce56772","type":"debug","z":"9425c1fec520a32f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":890,"y":220,"wires":[]},{"id":"e7cb91c2f19d45cf","type":"function","z":"9425c1fec520a32f","name":"","func":"return msg.payload;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":740,"y":160,"wires":[["a4eb5536cce56772"]]}]
Oh, I see! (every day is a school day) :) Thank you very much for your expertise and kind response! Wish you all the best with the keep up the good work!
No problem. Glad to help
Using the version 0.10.1 and doesn't matter how I try to apply overlay to control the node it's not overwriting the node config. In this example the node configured as Power Off (Heating On/Off = Heating Off) however when I try to send in payload to override it it's just ignoring it and submit whatever was configured in the node.
Here is my Flow:
[ { "id": "03886105d5ecea4d", "type": "debug", "z": "3126b8fa907db157", "name": "Tado Debug", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 710, "y": 460, "wires": [] }, { "id": "7982af501b6971d9", "type": "tado", "z": "3126b8fa907db157", "configName": "cf6e01dc41512c72", "apiCall": "setZoneOverlay", "homeId": "111111", "deviceId": "", "zoneId": "0", "power": "off", "temperature": "", "terminationType": "auto", "terminationTimeout": 900, "fanSpeed": "AUTO", "acMode": "AUTO", "name": "Set Hot Water State", "reportDate": "", "presence": "HOME", "geoTracking": true, "temperatureOffset": 0, "windowDetection": true, "windowDetectionTimeout": 900, "openWindowMode": true, "timetableId": "", "x": 460, "y": 460, "wires": [ [ "03886105d5ecea4d" ] ] }, { "id": "5382dc5ccd777980", "type": "inject", "z": "3126b8fa907db157", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "{\"power\":\"on\"}", "payloadType": "json", "x": 210, "y": 460, "wires": [ [ "7982af501b6971d9" ] ] }, { "id": "cf6e01dc41512c72", "type": "tado-config", "name": "" } ]
NOTE : I'm new to this and tried every possible syntax without success(string,JSON format,set topic, everything...). unfortunately the ReadMe not contain enough information how this suppose to look like.Getting back response:
Please Advise