Node-red to Drayton Wiser Interface

I am able to READ the status of a Drayton Wiser HeatHub as a JSON object using HTTP GET, but I am having difficulty understanding the correct syntax to do an HTTP PATCH command in order to WRITE data back to a Wiser Heat Hub on my local network, eg to change SetPoints.

I have found some code from two other (not node-red) applications:

HERE

AND HERE

Could somebody please help me with:

The syntax of an HTTP PATCH command including headers (if any)
The syntax of the path to the individual command/variables
The syntax of the payload

Any help would be greatly appreciated, TIA.

Hi, I also now have a Drayton Wiser boiler controller. I've not had much time to do anything smart using Node-RED though. I can certainly get the data from the controller.

I can see from first code you posted that you will need to understand the correct URL path in order to control anything. So the first thing you need to do is work out a command to use as a test. You can use msg.url in the form http://<controlleripaddr>/<command path>

You need to send a msg to the HTTP request node that contains msg.method = "PATCH" and a msg.headers property containing the "SECRET" and "HOST" headers as JSON.

After some quick experimentation, I was able to manually set the temperature override for room zero using the following code:

[{"id":"9d700a39.ebbaa8","type":"http request","z":"fb0c842.c87fc78","name":"","method":"use","ret":"obj","url":"","tls":"","x":770,"y":560,"wires":[["58845d6d.bf2a24"]]},{"id":"32c33bee.cf6c24","type":"inject","z":"fb0c842.c87fc78","name":"Wiser SET","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":560,"wires":[["855deb47.8df6f8"]]},{"id":"58845d6d.bf2a24","type":"debug","z":"fb0c842.c87fc78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":930,"y":560,"wires":[]},{"id":"6ec2a88e.839598","type":"change","z":"fb0c842.c87fc78","name":"","rules":[{"t":"set","p":"method","pt":"msg","to":"PATCH","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"\"http://\" & $flowContext('wiserHost') & $.path","tot":"jsonata"},{"t":"set","p":"headers","pt":"msg","to":"{\t    \"SECRET\": $flowContext('wiserSecret'),\t    \"HOST\": $flowContext('wiserHost') & \":80\"\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":560,"wires":[["9d700a39.ebbaa8"]]},{"id":"3822a01a.859ea","type":"inject","z":"fb0c842.c87fc78","name":"","topic":"Wiser QUERY","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":620,"wires":[["2dfd4a60.601b06"]]},{"id":"fcb37ac1.cb36f8","type":"http request","z":"fb0c842.c87fc78","name":"","method":"use","ret":"obj","url":"","tls":"","x":770,"y":620,"wires":[["c21166d6.4784c8"]]},{"id":"c21166d6.4784c8","type":"debug","z":"fb0c842.c87fc78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":930,"y":620,"wires":[]},{"id":"a9652fa4.60f24","type":"change","z":"fb0c842.c87fc78","name":"","rules":[{"t":"set","p":"method","pt":"msg","to":"GET","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"\"http://\" & $flowContext('wiserHost') & $.path","tot":"jsonata"},{"t":"set","p":"headers","pt":"msg","to":"{\t    \"SECRET\": $flowContext('wiserSecret'),\t    \"HOST\": $flowContext('wiserHost') & \":80\"\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":620,"wires":[["fcb37ac1.cb36f8"]]},{"id":"855deb47.8df6f8","type":"change","z":"fb0c842.c87fc78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"RequestOverride\":{\"Type\":\"Manual\",\"SetPoint\":-200}}","tot":"json"},{"t":"set","p":"path","pt":"msg","to":"/data/domain/Room/1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":560,"wires":[["6ec2a88e.839598"]]},{"id":"2dfd4a60.601b06","type":"change","z":"fb0c842.c87fc78","name":"","rules":[{"t":"set","p":"path","pt":"msg","to":"/data/domain/","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":620,"wires":[["a9652fa4.60f24"]]}]

Note that the flow also includes the query. The IP address of the controller & the secret for control are both set as flow variables (flow.wiserHost and flow.wiserSecret) so you will need to set those up yourself.

I don't know all of the control types by any means but I will try to document some as I go along.

Hi Julian

Thank you so much for the pointers, I have imported your experiment and I am looking into it now...

Kind regards, Dave

No problem. Thanks for prompting me to get on and work out the control process :slight_smile:

In fact, I've added a new Node-RED blog post on the subject with lots of additional information and some extra examples. You might want to check out the paths and payloads needed for different controls.

Have fun and let me know if you spot any mistakes or want to add to the post.

Good morning Julian, I wish I had the skills to create a solution so quickly - I have been struggling for ages with how to change the set point! Thank you also for the blog post, just please check the formatting as the text is running off the RHS of the screen...

Thanks. Yes, I discovered that as I was writing but didn't have time to fix it. I've recently moved over to using Hugo for my website, the code blocks are a standard feature but something in my CSS is causing an issue. Pasting Node-RED flows is particularly challenging since they are so big and you get some VERY long lines that can't be split.

TIP
When looking for the system secret, I found the IP address of the HeatHub whilst it was in setup mode (actually, always 192.168.8.1), temporarily altered the IP address of my Mac to be on the same domain (eg 192.168.8.10) and simply browsed 192.168.8.1/secret.

1 Like

I am able to change the set points using my own javascript code with the desired setpoint as part of the payload with input from another part of a flow and/or a UI, but how can I configure standard node-red nodes, to do the same thing?

Also, I often use node-red in the cloud using bluemix, so do you know whether it is possible to update these same set points and monitor room temps via the Wiser cloud services ("api-nl.wiserair.com" and/or "bootstrap.gl.struxurewarecloud.com")? Or am I going to have to open up a port to gain remote access?

Sorry, I don't quite follow. I've not used any JavaScript code in my example flows. It should be easy enough to amend the control example so that you can pass the required setpoint in via a msg. You will note that, in my example, the inject node is only used to start the flow but it could send a number as a payload that you could then use in the first change node.

Sorry, I don't know the answer. I think that you would need to put a monitor onto your phone in order to capture the dialogue from the cloud site to your phone. Probably only doable with an Android phone/tablet.

For my own use, and my recommendation, is that I only want to allow access from Node-RED to the controller on my own, controlled network, indeed, you should seriously consider creating a local VLAN to segment your IoT/Home Automation traffic from general traffic for security.

I use a Telegram bot to enable control of my HA system from the Internet since that takes care of all of the security including authentication, authorisation and encryption. Getting (and keeping) all of that right yourself is a pain and easily compromised.

Telegram bots let you easily create both command and conversation driven interfaces. The bot logic is, of course, hosted on my Node-RED service. However, I've not yet set up the bot logic to handle heating, only lighting.

I will probably create some standard heating scenarios (most likely a couple) that I can easily switch between since the mobile app doesn't allow you to do that. Controlling individual rooms I might as well continue to do through the mobile app but I would rarely, if ever, want to do that remotely anyway. So the interface would be really easy to create using a Telegram bot since I would only need to switch between the 2 scenarios.

I should probably emphasise that, especially when dealing with automation of your home's heating system, security is CRITICAL. In my view, it is only a matter of time before someone comes home to a seriously expensive bill or even a burned out house thanks to a poorly secured home automation system. I would hate for that to be someone who uses Node-RED.

I work in security and so I can say with confidence that this is not a theoretical risk. There are 10's of millions of compromised systems on the Internet running bots that constantly trawl the Internet looking for new systems to manipulate. There are also thousands of people who's full time job is looking for compromisable systems.

Hi Julian, I will ensure that my systems will not be one of those compromised and thank you again for your assistance.

1 Like