Home Automation

Mosquitto MQTT and Home Assistant Data Logging

Using Mosquitto MQTT and Home Assistant Data to log sensor data for our home using different types of wired and wireless sensors

We have removed the Raspberry Pi based data logger from our home and moved the logging hardware and new software to the Gigabit Internet Gateway Network PC which we installed in December 2017.

New Data logging computer

The old Raspberry Pi system was initially designed to log the 12V off grid system as well as house temperatures and mains electric usage.

As we removed the 12V off grid system around 18 months ago the Raspberry Pi was only logging data from the Wireless Things temperature and environmental sensors and the 1-Wire sensors on the hot water system.

We wanted to be able to also store the data locally and it being accessible using different applications and so we had to either use a local database or other method of sharing and updating the sensor data. A lot of home automation systems now use MQTT to send and receive data and so we decided to use this and installed the Mosquitto open source MQTT broker https://mosquitto.org/ on the Linux box.

Temperature Sensors

We had a Wireless Things USB to Serial adapter which is mounted as a UART port on Linux and a USB 1-Wire adapter which we connected to our 1-Wire temperature sensors.

To access the 1-Wire sensors we installed OWFS which mounts the sensors in the file system.

Andrew has written a C application which accesses the various sensors and sends this to the MQTT broker.

Mains Energy and Gas Logging

The ESP8266 Mains Energy Monitor project was being uploaded to the reporting website every minute using a python script and cron job. The firmware on this was updated to also publish a MQTT message every 30 seconds to the MQTT broker with the gas and electric meter readings and the mains current usage.

Local Reporting using Home Assistant

For local network reporting we installed Home Assistant on our Synology Diskstation using a Docker image and this allows all our computers, tablets and phones to view the data using an easy to use and update interface.

The Home Assistant software also allowed us to add our Nest Smoke Alarms and Nest Thermostat data to the reporting pages. Nest do not have any API methods for accessing the thermostats hot water controls or settings which would have made automating the hot water controls much easier as we could have used the sensor data from the solar hot water system to set the times needed to heat the water based on the existing hot water tank temperature. Below are screen shots of the data reporting pages:

Overview / Home page

Home Assistant home page

Downstairs sensors page

Downstairs sensors page

Upstairs sensors page

Upstairs sensors page

Loft sensors page

Loft sensors page

Outdoors sensors page

Outdoors sensors page

Heating and Hot Water sensors page

Heating and Hot Water sensors page

Nest Smoke Alarms page

Nest Smoke Alarms page

Remote Reporting

For our online data logger website at http://home.briandorey.com/ Andrew wrote a new python script which has two timers to subscribe to the MQTT broker and upload at different intervals for the mains and gas logger every minute and the temperature sensors and environmental sensors every five minutes.

The source code for the new software and Home Assistant config are available on GitHub at https://github.com/briandorey/MQTT-HomeAssistant



14 March 2018 at 9:42 pm
21 August 2019 at 3:09 pm
HI, nice blog!
What type of CO,Smok detector you use? How you measure the status of a battery?
21 August 2019 at 6:50 pm
Miro, we are using the smoke detectors from Nest

Leave a reply

Your email address will not be published. Required fields are marked *

Share this post

Support the blog

AB Electronics Raspberry Pi shop