Category Archives: MQTT

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”:”49ec9dd5.c83ccc”,”type”:”tab”,”label”:”Hive”},{“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\”: \”USERNAME@USER.COM\”,\”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”:[[“fdc0e48e.ac08a8″,”439db97.234c248″,”34c5db4d.1fc25c”,”6faf9e8f.ff645″,”1056f9eb.f58fee”,”b17dc096.112d68″]]},{“id”:”fdc0e48e.ac08a8″,”type”:”contrib-json”,”z”:”49ec9dd5.c83ccc”,”engine”:”JSONPath”,”command”:”jq”,”expr”:”$…attributes.temperature.reportedValue”,”complete”:”property”,”prop”:”payload”,”name”:”Get temperature”,”x”:418.666748046875,”y”:312.91668701171875,”wires”:[[“bc60a6cc.b97d”]]},{“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”]]},{“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”:”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”:””}]

 

 

 

IoTBox and the Internet of Things Foundation

The IoTBox was born out of the realisation that we needed a physical “tool” to show how we can interact with other systems – such as IBM Maximo. We have always talked about how easy it is to integrate – but how could we prove it?.

The IoTBox started with the ability to use REST calls to update mqttsystems with temperature readings. This was useful, but hardly IoT!. Next, MQTT support was added – the temperature can be sent, along with Button presses to an MQTT broker and the RGB LED and screen can be changed with MQTT messages. This, combined with Node Red, allows us to manipulate messages,  create alerts and provide ‘intelligence’ to the small processor in the IoTBox.

However, although we can talk to our servers and pcs across the Internet – this is not really cloud based.

iotThumbWith this in mind, I decided to also add the ability for the IoTBox to talk with IBM’s Internet of Things Foundation. This cloud offering is free to use for development and includes services such as Node Red, Real Time Analytics, Time Series databases and of course – Watson!.

The IoTF Real Time Analytics Team have made some great enhancements recently: The ability to create alerts from sensor values – this includes E-mail, Node Red calls and now IFTTT integration!.

The IoTBox will use both modes of IoTF – Quickstart (no registration required) and Registered (allows the full use of IoTF).

Screen Shot 2015-11-30 at 17.04.53The new IoTF Registered mode allows the LED and OLED screen to be controlled by the IoTF cloud.

For example, a cloud based Maximo offering can create a  work order based on a temperature reading from the IoTBox. The LED on the IoTBox could turn blue and a message on the screen will alert the user to the new work order number.

This is now very easy to do!. In the following post, I will detail the full steps required to connect to IBM’s IoTF cloud service.

 

IoTBox Videos

I have uploaded a couple of videos to describe the function of the IoTBox (while I am waiting for components from China to do the build videos!)

A run though of the web interface menu system:

The IoTBox in operation: 

IoTBox Hardware

Here is the final parts list for the IoTBox. Each item links to the version that I used. They may link to multipacks (I built 30-35 IoTBoxes) but you only need 1 unless noted.

2015-06-28 14.38.24
The final IoTBox

During the beta testing I have tried and killed many boxes and components to get this far. Hopefully it will save you some time and expense. Note that many items came via China to reduce the unit price.

Parts List Continue reading IoTBox Hardware

IoTBox. First steps…

“I want one! – actually can I have 30?”

I took my idea to a few people – the inventors of NodeRed and a couple of members of the team and they thought that the idea was sound – produce a simple IoTBox that we can use in demonstrations to show how connected devices can make use of our products. I was then asked “Can we have 30 ready in a few weeks?”. I had better work fast!.

Continue reading IoTBox. First steps…

IoTBox – an Internet of Things, thingy.

The final version of the IoTBox

2015-06-28 14.38.19
The final version

The IoTBox is a small 5x5cm device with an OLED screen that displays MQTT messages, an RGB LED to show MQTT messages as a status colour, a button that triggers an MQTT message and a waterproof temperature sensor that sends MQTT messages and/or a REST call. It can be updated “OTA” and is powered by the USB connector.

These articles will show you how to build one.

Background to IoTBox

Back in December 2014, I started to look at a new Wifi chip that had just been released as a means of Internet enabling various Arduino projects that I had been thinking about. I soon realised that this processor (the ESP8266) was actual more powerful than the Arduino and much much cheaper.

Continue reading IoTBox – an Internet of Things, thingy.

Node Red, MQTT and Tado

I use Node Red and MQTT around the house for a simple home automation system. After getting Tado installed, I wondered how easy it would be to link it in. Actually, it is very easy:

image

This flow pulls info from the Tado site every minute and creates MQTT messages for my other flows to pick up. As I have other wireless temperature nodes around the house, I could spot that the heating is on and a window is open by looking at temperature differences around the house.

Continue reading Node Red, MQTT and Tado