# Node-red to Drayton Wiser Interface

**URL:** <https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046>\
**Category:** General\
**Created:** [4 August 2018 08:16 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046 "2018-08-04T08:16:13Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidparker](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidparker](https://discourse.nodered.org/u/davidparker)\
**Post date:** [4 August 2018 08:16 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/1 "2018-08-04T08:16:13Z")

</div>

> **[Welcome to the Wiser Smart Thermostat](https://wiser.draytoncontrols.co.uk/)**
>
> Introducing Wiser, the beautifully simple heating system from Drayton.

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

> <https://github.com/chrisduffer/drayton-wiser/blob/master/smartapps/chrisduffer/drayton-wiser-connect.src/drayton-wiser-connect.groovy>

AND HERE

> <https://github.com/andrew-schofield/openhab2-addons/blob/draytonwiser/addons/binding/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/handler/HeatHubHandler.java>

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 August 2018 16:31 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/2 "2018-08-13T16:31:12Z")

</div>

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:

```json
[{"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.

---

<div class="post-metadata">

**Author:** ![davidparker](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidparker](https://discourse.nodered.org/u/davidparker)\
**Post date:** [13 August 2018 17:27 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/3 "2018-08-13T17:27:17Z")

</div>

Hi Julian

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

Kind regards, Dave

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 August 2018 23:05 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/4 "2018-08-13T23:05:20Z")

</div>

> [@davidparker](#):
>
> Thank you so much for the pointers, I have imported your experiment and I am looking into it now...

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

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.

> **[Drayton Wiser heating control](https://it.knightnet.org.uk/kb/nr-qa/drayton-wiser-heating-control/)**
>
> Drayton are a very widely used manufacturer of heating controls. They make the "Wiser" control system which is low cost and easily fitted. This article shows you how to use Node-RED to query and control the system.

---

<div class="post-metadata">

**Author:** ![davidparker](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidparker](https://discourse.nodered.org/u/davidparker)\
**Post date:** [14 August 2018 06:10 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/5 "2018-08-14T06:10:25Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 August 2018 06:12 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/6 "2018-08-14T06:12:58Z")

</div>

> [@davidparker](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![davidparker](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidparker](https://discourse.nodered.org/u/davidparker)\
**Post date:** [14 August 2018 06:30 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/7 "2018-08-14T06:30:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![davidparker](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidparker](https://discourse.nodered.org/u/davidparker)\
**Post date:** [14 August 2018 07:27 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/8 "2018-08-14T07:27:24Z")

</div>

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](http://api-nl.wiserair.com)" and/or "[bootstrap.gl.struxurewarecloud.com](http://bootstrap.gl.struxurewarecloud.com)")? Or am I going to have to open up a port to gain remote access?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 August 2018 20:48 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/9 "2018-08-14T20:48:39Z")

</div>

> [@davidparker](#):
>
> 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?

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.

> [@davidparker](#):
>
> 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](http://api-nl.wiserair.com)" and/or "[bootstrap.gl.struxurewarecloud.com](http://bootstrap.gl.struxurewarecloud.com)")? Or am I going to have to open up a port to gain remote access?

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 August 2018 20:55 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/10 "2018-08-14T20:55:41Z")

</div>

> [@davidparker](#):
>
> I often use node-red in the cloud using bluemix

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.

---

<div class="post-metadata">

**Author:** ![davidparker](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidparker](https://discourse.nodered.org/u/davidparker)\
**Post date:** [17 August 2018 16:55 UTC](https://discourse.nodered.org/t/node-red-to-drayton-wiser-interface/2046/11 "2018-08-17T16:55:42Z")

</div>

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