Hive Thermostat flow

Currently the flow for Node Red is ReadOnly – I use it to interrogate the status for Alexa and other things. It will be quite easy to modify to update settings.

Note that you will need to add the node-red-contrib-json node to the palette. With NR now supporting JSONata, we may be able to tune this a little!.

You will need to set your Username and Password as well as your MQTT topics. Rough code but works reliably!


[{"id":"643b2abe.1e50ec","type":"inject","z":"49ec9dd5.c83ccc","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"x":220.5,"y":83.75,"wires":[["19b17aca.6a05ad"]]},{"id":"208e46fe.e89bea","type":"http request","z":"49ec9dd5.c83ccc","name":"","method":"POST","ret":"txt","url":"","tls":"","x":595.5,"y":84.75,"wires":[["76b6ab17.670644"]]},{"id":"19b17aca.6a05ad","type":"function","z":"49ec9dd5.c83ccc","name":"Build Hive Login","func":"//msg.url = \"https://api.prod.bgchprod.info:443/omnia/auth/sessions\";\nmsg.url = \"https://api-prod.bgchprod.info/omnia/auth/sessions\";\nmsg.headers = {\"Content-Type\": \"application/vnd.alertme.zoo-6.1+json\", \"Accept\":\"application/vnd.alertme.zoo-6.1+json\",\"X-Omnia-Client\":\"Hive Web Dashboard\"};\nmsg.payload = {\"sessions\": [{\"username\": \"[email protected]\",\"password\": \"password\",\"caller\":\"WEB\"}]};\nreturn msg;","outputs":1,"noerr":0,"x":402.5,"y":83.75,"wires":[["208e46fe.e89bea"]]},{"id":"76b6ab17.670644","type":"json","z":"49ec9dd5.c83ccc","name":"","x":751.5,"y":84.75,"wires":[["3cd7fbe0.459b8c"]]},{"id":"43e03b7.f0a7844","type":"function","z":"49ec9dd5.c83ccc","name":"Build Nodes request","func":"//sessionid = msg.payload.sessions[0].id;\n//msg.url = \"https://api.prod.bgchprod.info:443/omnia/nodes\";\nmsg.url = \"https://api-prod.bgchprod.info/omnia/nodes\";\nmsg.headers = {\"Content-Type\": \"application/vnd.alertme.zoo-6.1+json\", \"Accept\":\"application/vnd.alertme.zoo-6.1+json\",\"X-Omnia-Client\":\"Hive Web Dashboard\", \"X-Omnia-Access-Token\":global.get(\"hivesessionid\")};\nreturn msg;","outputs":1,"noerr":0,"x":408.24993896484375,"y":164,"wires":[["f9ac83a3.ffcaa8"]]},{"id":"f9ac83a3.ffcaa8","type":"http request","z":"49ec9dd5.c83ccc","name":"","method":"GET","ret":"txt","url":"","tls":"","x":608.2499389648438,"y":166.25,"wires":[["19a14632.8d09ba","a31f8007.ebaa68"]]},{"id":"19a14632.8d09ba","type":"json","z":"49ec9dd5.c83ccc","name":"","x":157.5,"y":319.2500305175781,"wires":[["439db97.234c248","34c5db4d.1fc25c","6faf9e8f.ff645","1056f9eb.f58fee","b17dc096.112d68","7d797a80.740444"]]},{"id":"bc60a6cc.b97d","type":"json","z":"49ec9dd5.c83ccc","name":"","x":626.25,"y":314.2500305175781,"wires":[["4cf41c36.04afc4"]]},{"id":"439db97.234c248","type":"contrib-json","z":"49ec9dd5.c83ccc","engine":"JSONPath","command":"jq","expr":"$...attributes.stateHeatingRelay.reportedValue","complete":"property","prop":"payload","name":"Heating Relay","x":424.75,"y":403.91668701171875,"wires":[["edaf4660.36566"]]},{"id":"edaf4660.36566","type":"json","z":"49ec9dd5.c83ccc","name":"","x":636.333251953125,"y":406.2500305175781,"wires":[["a585d597.5cac6"]]},{"id":"34c5db4d.1fc25c","type":"contrib-json","z":"49ec9dd5.c83ccc","engine":"JSONPath","command":"jq","expr":"$...attributes.activeHeatCoolMode.reportedValue","complete":"property","prop":"payload","name":"Heating Mode","x":449.5,"y":552.6666870117188,"wires":[["7642a894.1bf51"]]},{"id":"7642a894.1bf51","type":"json","z":"49ec9dd5.c83ccc","name":"","x":672.3331909179688,"y":602.75,"wires":[["52dae72f.0aa0f8"]]},{"id":"6faf9e8f.ff645","type":"contrib-json","z":"49ec9dd5.c83ccc","engine":"JSONPath","command":"jq","expr":"$...attributes.stateHotWaterRelay.reportedValue","complete":"property","prop":"payload","name":"HotWater Relay","x":432.75,"y":446.91668701171875,"wires":[["d122a54f.c59c7"]]},{"id":"d122a54f.c59c7","type":"json","z":"49ec9dd5.c83ccc","name":"","x":641.333251953125,"y":449.2500305175781,"wires":[["2c57f758.a707a8"]]},{"id":"b7ec3fdf.c49938","type":"debug","z":"49ec9dd5.c83ccc","name":"serverConnectionState","active":false,"console":"false","complete":"payload","x":1053.8336181640625,"y":538.25,"wires":[]},{"id":"1056f9eb.f58fee","type":"contrib-json","z":"49ec9dd5.c83ccc","engine":"JSONPath","command":"jq","expr":"$...attributes.serverConnectionState.reportedValue","complete":"property","prop":"payload","name":"serverConnectionState","x":464.75,"y":500.91668701171875,"wires":[["894fb7ac.cfa1d"]]},{"id":"894fb7ac.cfa1d","type":"json","z":"49ec9dd5.c83ccc","name":"","x":651.333251953125,"y":503.2500305175781,"wires":[["5f5991d1.00008"]]},{"id":"b17dc096.112d68","type":"contrib-json","z":"49ec9dd5.c83ccc","engine":"JSONPath","command":"jq","expr":"$...attributes.targetHeatTemperature.reportedValue","complete":"property","prop":"payload","name":"Get target temperature","x":440.75,"y":356.91668701171875,"wires":[["70a8237c.8363ec"]]},{"id":"70a8237c.8363ec","type":"json","z":"49ec9dd5.c83ccc","name":"","x":637.333251953125,"y":358.2500305175781,"wires":[["25f2ae4e.9c5a5a"]]},{"id":"13de7ae0.7c8d1d","type":"split","z":"49ec9dd5.c83ccc","name":"","splt":"\",\"","x":1001.25,"y":618.7500610351562,"wires":[["fc978ec0.2df78"]]},{"id":"e421221f.c966d8","type":"debug","z":"49ec9dd5.c83ccc","name":"Water Mode","active":false,"console":"false","complete":"payload","x":998,"y":673.75,"wires":[]},{"id":"5f5991d1.00008","type":"change","z":"49ec9dd5.c83ccc","name":"normalise","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":813.25,"y":509.2500305175781,"wires":[["b7ec3fdf.c49938"]]},{"id":"2c57f758.a707a8","type":"change","z":"49ec9dd5.c83ccc","name":"normalise","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":814.5,"y":456.7500305175781,"wires":[["8ce96ab4.aea148","b0c156b1.ee8dd"]]},{"id":"a585d597.5cac6","type":"change","z":"49ec9dd5.c83ccc","name":"normalise","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":813.75,"y":406.2500305175781,"wires":[["4057512f.4dea3"]]},{"id":"25f2ae4e.9c5a5a","type":"change","z":"49ec9dd5.c83ccc","name":"normalise","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":803.75,"y":358.2500305175781,"wires":[["7b8abb6b.1f7cdc"]]},{"id":"4cf41c36.04afc4","type":"change","z":"49ec9dd5.c83ccc","name":"normalise","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":796.75,"y":312.2500305175781,"wires":[["f3372eb1.b86198","a43ff107.11564"]]},{"id":"fc978ec0.2df78","type":"switch","z":"49ec9dd5.c83ccc","name":"Split Water and Heating","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"[\"","vt":"str"},{"t":"else"}],"checkall":"true","outputs":2,"x":548.75,"y":689.75,"wires":[["9742b21d.50a868"],["f94862f4.182f48"]]},{"id":"9742b21d.50a868","type":"change","z":"49ec9dd5.c83ccc","name":"normalise","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":787,"y":691.25,"wires":[["e421221f.c966d8","fc06b2e3.f48de8"]]},{"id":"f94862f4.182f48","type":"change","z":"49ec9dd5.c83ccc","name":"normalise","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":781,"y":748.25,"wires":[["c3a97850.7968f8","755c2a0a.bb6614"]]},{"id":"52dae72f.0aa0f8","type":"change","z":"49ec9dd5.c83ccc","name":"Change","rules":[{"t":"change","p":"payload","pt":"msg","from":"HEAT","fromt":"str","to":"SCHEDULED","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":837.375,"y":617.25,"wires":[["13de7ae0.7c8d1d"]]},{"id":"c3a97850.7968f8","type":"debug","z":"49ec9dd5.c83ccc","name":"Heating Mode","active":false,"console":"false","complete":"payload","x":969.875,"y":833,"wires":[]},{"id":"3cd7fbe0.459b8c","type":"function","z":"49ec9dd5.c83ccc","name":"set hivesessionid","func":"global.set(\"hivesessionid\",msg.payload.sessions[0].id);\nreturn msg;","outputs":1,"noerr":0,"x":933.125,"y":85,"wires":[["43e03b7.f0a7844"]]},{"id":"f058b4fb.4a2ef8","type":"http request","z":"49ec9dd5.c83ccc","name":"","method":"DELETE","ret":"txt","url":"","tls":"","x":1034.375,"y":170,"wires":[[]]},{"id":"a31f8007.ebaa68","type":"function","z":"49ec9dd5.c83ccc","name":"Close Session","func":"\nmsg.url = \"https://api-prod.bgchprod.info/omnia/auth/sessions/\"+global.get(\"hivesessionid\");\nmsg.headers = {\"Content-Type\": \"application/vnd.alertme.zoo-6.1+json\", \"Accept\":\"application/vnd.alertme.zoo-6.1+json\",\"X-Omnia-Client\":\"Hive Web Dashboard\", \"X-Omnia-Access-Token\":global.get(\"hivesessionid\")};\nreturn msg;","outputs":1,"noerr":0,"x":847.5,"y":168.75,"wires":[["f058b4fb.4a2ef8"]]},{"id":"f3372eb1.b86198","type":"mqtt out","z":"49ec9dd5.c83ccc","name":"","topic":"House/Hive/heating/temperature","qos":"","retain":"","broker":"34fe01cb.7a1b06","x":1111.875,"y":270.9375,"wires":[]},{"id":"7b8abb6b.1f7cdc","type":"mqtt out","z":"49ec9dd5.c83ccc","name":"","topic":"House/Hive/heating/target","qos":"","retain":"","broker":"34fe01cb.7a1b06","x":1093.75,"y":328.75,"wires":[]},{"id":"4057512f.4dea3","type":"mqtt out","z":"49ec9dd5.c83ccc","name":"","topic":"House/Hive/heating/relay","qos":"","retain":"","broker":"34fe01cb.7a1b06","x":1080,"y":373.75,"wires":[]},{"id":"8ce96ab4.aea148","type":"mqtt out","z":"49ec9dd5.c83ccc","name":"","topic":"House/Hive/water/relay","qos":"","retain":"","broker":"34fe01cb.7a1b06","x":1080,"y":423.75,"wires":[]},{"id":"fc06b2e3.f48de8","type":"mqtt out","z":"49ec9dd5.c83ccc","name":"","topic":"House/Hive/water/control","qos":"","retain":"","broker":"34fe01cb.7a1b06","x":1060.5,"y":725,"wires":[]},{"id":"b0c156b1.ee8dd","type":"debug","z":"49ec9dd5.c83ccc","name":"","active":false,"console":"false","complete":"false","x":1028.5,"y":481.75,"wires":[]},{"id":"755c2a0a.bb6614","type":"mqtt out","z":"49ec9dd5.c83ccc","name":"","topic":"House/Hive/heating/control","qos":"","retain":"","broker":"34fe01cb.7a1b06","x":1062,"y":788,"wires":[]},{"id":"15a3ca8b.7e044d","type":"comment","z":"49ec9dd5.c83ccc","name":"WARNING!!!","info":"this bit is clunky - \nI should find a better way to make sure \nwhich is water and which is heating\nrather than taking the order into account.\n\n\n","x":470,"y":643.75,"wires":[]},{"id":"c35a4515.4944f8","type":"comment","z":"49ec9dd5.c83ccc","name":"PASSWORD!","info":"","x":404,"y":49,"wires":[]},{"id":"7d797a80.740444","type":"contrib-json","z":"49ec9dd5.c83ccc","engine":"JSONPath","command":"jq","expr":"$...attributes.temperature.reportedValue","complete":"property","prop":"payload","name":"Get temperature","x":420,"y":300,"wires":[["bc60a6cc.b97d"]]},{"id":"a43ff107.11564","type":"debug","z":"49ec9dd5.c83ccc","name":"","active":false,"console":"false","complete":"false","x":1026,"y":224.5,"wires":[]},{"id":"34fe01cb.7a1b06","type":"mqtt-broker","z":"","broker":"192.168.1.22","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""}]

 
(updated 19th Oct 2017)
 

 

8 thoughts on “Hive Thermostat flow”

  1. I eventually managed to get your flow here to work for me, but encountered two/three problems along the way:

    1: copying this JSON flow as HTML results in the quote marks not being interpreted by NodeRed as quotes, so you have to paste the code into a text editor, search and replace the quotes, and then the import from Clipboard will work.

    2: The same problem also produces a much more subtle issue: the JSONpath expressions all have a single elision character embedded in them instead of three separate dots, meaning that the expressions don’t work and no data is returned. You have to manually edit each contrib-json node’s expression in NodeRed to delete the ‘$…’ that is in there and manually re-type ‘$…’ The result looks the same, but will actually work now where it didn’t before.

    3: My Hive setup has two devices that produce temperature values, so I get an array out of the ‘heating/temperature’ call instead of a single value, which confuses the subsequent parsing and produces no value for the content. To fix this, either correct the JSONpath expression to get just the first value, or to select the one with just the nodeType of thermostat (neither of which I managed to do despite much fiddling with JSONpath expressions) or just add a Regular Expression onto the end of the ‘normalise’ node to replace everything from the comma onwards, so the expression is “,.*” (without the quote marks).

    So ideally, if you could paste in the JSON code in raw format instead of HTML that would fix the first two issues and save someone else some hours of debugging …

  2. OK, so I’ve fixed the JSONpath expression for problem #3 now. If you use this in the “Get Temperature” contrib-json node then you pick up the temp only from the thermostat, even if there are other temp devices around:
    $..[?(@.nodeType==’http://alertme.com/schema/json/node.class.thermostat.json#’)].attributes.temperature.reportedValue.

  3. Below is the acurate way of getting hold of the current selected mode for Heating (AUTO/OFF/MANUAL) the settings you ahve above are the only way to get hold of the ‘BOOST’ notification. This returns 2 values (what it is now and what it was previously)

    $..nodes[4].attributes.previousConfiguration.reportedValue.mode

    The same for Hot Water is
    $..nodes[5].attributes.previousConfiguration.reportedValue.mode

  4. Sadly, looks like Hive, in their wisdom have discontinued this API – i just get a “No Longer Supported” Response.

    1. That’s true.
      I believe there is still a way to do it but I am using the Home Assistant integration to collect the info and send to node red now.

Leave a Reply to Dave Postle Cancel reply

Your email address will not be published.