Securing MySensors network

Some months ago I decided it was time to secure my steadily growing MySensors network. As described on the MySensors website this can be implemented by using a software or hardware solution to sign messages. I chose the hardware solution using the ATSHA204A component. Because the more convenient break-out board was out of stock, I ordered a little strip of 3-legged ATSHA204A surface mounted devices (SMD). But when they arrived I was struck by the size of those things.

Feeling steady handed today I took the nerve to solder one of them to put on my gateway device. This gateway device consists of a Arduino Uno, Ethernet shield (W5100) and nRF24L01+ PA/LNA. There are some nodes (Sensebender Micro) in the house which are already equipped with an ATSHA204A.

Somewhat proud of my accomplishment I like to share some picture of what it looks like.

Curious and want to know more about securing MySensors, check out the following page.

MQTT and openHAB adventure

Some people asked me to share my MQTT setup in regard to openHAB and I agreed to do so. In this blog post I will explain and describe in more detail my current setup primarily on the heating subject.

But first some background info. A long time ago I installed openHAB 1.6 on a Raspberry Pi 2 and started with some Homematic and Enocean (devkit) devices, but learned there were more interesting alternatives and fell in love with the MySensors project. This project allows you to create your own home automation devices with Arduino and alike hardware and provides a library that will handle all communication between the devices and openHAB. Since I started with MySensors I have used MQTT to connect to openHAB, so I already had a working MQTT setup when the OpenTherm gateway entered the house.

Setting up MQTT is pretty straightforward. Below I describe the steps I took to install and configure MQTT in combination with openHAB.

  1. $ sudo apt-get install mosquitto
    This installs version 0.15 of the software from the default repository. In my recent journey to upgrade MySensors from 1.5 to 2.1 I had to upgrade the mosquitto software to a newer release to make it work again.
  2. Upgrade mosquitto (optional)
    $ cd /etc/apt/sources.list.d/
    $ sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
    $ sudo apt-get update
    $ sudo apt-get install mosquitto
  3. Start the moquitto service
    $ sudo service mosquitto start
  4. Install MQTT openHAB binding (assuming openHAB is installed from the repo).
    $ sudo apt-get install openhab-addon-binding-mqtt
    otherwise place the MQTT addon binding in the right directory
  5. Configure the openHAB MQTT binding
    edit the openHAB main config file: /etc/openhab/configurations/openhab.cfg
    mqtt:mybroker.url=tcp://localhost:1883
    mqtt:mybroker.clientId=openHAB
  6. Restart openHAB
    $ sudo service openhab restart
  7. Check if the addon is loaded and reports an connection:
    $ sudo tailf /var/log/openhab/openhab.log | grep -i mqtt
    2016-11-06 16:40:29.047 [INFO ] [.io.transport.mqtt.MqttService] – MQTT Service initialization completed.
    2016-11-06 16:40:29.050 [INFO ] [o.i.t.m.i.MqttBrokerConnection] – Starting MQTT broker connection ‘mybroker’

Now that openHAB is configured to listen to the MQTT message bus it’s time to hook up the OpenTherm gateway.

I will continue in another post to explain the OpenTherm gateway configuration and openHAB items and rules. Also some useful debugging commands which I use alot. This was drafted pretty quickly, so the layout is not that nice. Hopefully I will find some time to tidy up the styling..

That’s it for now, more to follow on this subject soon!

Fixing runaway setpoint value

It’s not really a fix. It’s better to speak of a workaround to correct the setpoint of the household thermostat which slowly shifts over time (see the graph above). I lack knowledge to fix the source, which is most probably the OTGW software. So I have created a rule in openHAB to check and fix the setpoint every time it gets updated.

If someone else experience this behavior, the rule below works for me!

rule "Correct setpoint"
when
  Item ot_setpoint received update
then
  var float CurrentSetpoint = (ot_setpoint.state as DecimalType).floatValue
  logInfo("home.rules", "ot_setpoint before: " + CurrentSetpoint)

  var float CorrectSetpoint = Math::round(CurrentSetpoint.floatValue*2)/2.0f
  logInfo("home.rules", "ot_setpoint after: " + CorrectSetpoint)

  if (CorrectSetpoint != CurrentSetpoint) {
    postUpdate(ot_setpoint, CorrectSetpoint)
    logInfo("home.rules", "ot_setpoint correction performed")
  }
end