I’ve had it in my mind to control the heating of the house via the computer for a while now, but my first requirement was always to monitor the environment, so the computer can at least make an informed decision about whether the heating is *actually* required.

A while ago I purchased an RFXCom transceiver for my home automation needs, and it’s been one of the best decisions I’ve made with regards to home automation. Not only can it transmit and receive LightwaveRF signals, it can also do Byron, Nexa, X10, Oregon Scientific, and a whole tonne more.

I subsequently discovered these dirt cheap Imagintronix humidity and temperature transmitter devices, which you can buy for £7 each. The temperature sensor needs to be calibrated against a known source, and you then apply the difference to the device as it is picked up in Domoticz. It’s all rather simple, and you immediately have a source of temperature data that can be used. I took a variety of these sensors, and put one in each room, and rather quickly gained an overview of the house from within Domoticz.

Room temperatures

Next up was the desire to average out these temperatures per zone. We have a very simple heating system with only one zone, so it was a simple case of averaging all the temperatures to get one value that we can notionally call the ‘Average house temperature’

The issue here is that Domoticz can’t do that sort of simple calculation. It has a Blockly engine built in to it, but I didn’t see any way of making do simple calculations. However, there was a way around that…

I already use the mqtt.js script from http://www.domoticz.com/wiki/Setup_MQTT_support_to_connect_external_devices to publish MQTT messages from Domoticz, and Node-Red to do some other MQTT management things, so it was just a case of getting Node-Red to do the work instead, and then to JSONify it and push it back into Domoticz.

[{"id":"b75445a3.48abb8","type":"function","name":"JSONify","func":"msg.payload = '{\"idx\":46,\"svalue\":\"' + msg.payload + ';0;0\"}';\nreturn msg;","outputs":1,"x":495,"y":463,"z":"d5caab33.2a3558","wires":[["a4bce105.5b432"]]}]

Sorted, there’s now a dummy temperature sensor in Domoticz with IDX 46, and Node-Red emits a MQTT message with the appropriate JSON content for Domoticz to pick up and use with the temperature sensor.

Average temperature

Next step is to actually use that data…