Recently I was researching into home automation systems. What I wanted to do was have temperature sensors in different locations around my house and integrate this environmental information into one place, where the data could be logged and monitored. What I discovered was open source software called Home Assistant.

I had a spare Raspberry Pi 3 B+ and wanted to put it to good use. I downloaded their 32-bit installation file from the Home Assistant website (or “Hassio” as they are also known). I used a 64GB MicroSD card for the install. Hassio recommend a minimum 32GB (as the system does eventually hold a database of all your sensor data on it. The bigger the space, the more data it will store).

The temperature sensors I decided to go with were called Xiaomi Mi Temperature and Humidity sensors. They are simple in design, but crucially also bluetooth enabled.

However, Home Assistant does not directly “see” these temperature sensors. Another piece of kit was required, called an ESP32. It’s a tiny circuit board designed for tinkerers and developers. The tiny USB-powered ESP32 is a wifi and bluetooth enabled device that can be programmed to analyse your home wifi network as well as any nearby bluetooth devices. I connected the ESP32 to my laptop and ran software called ESPHome-Flasher. This opened the device communication, and allowed the device to show me what bluetooth devices it was seeing. Every time one of the temperatures updated, it appeared in the ESPHome-Flasher window, along with it’s MAC address. I was then able to create a firmware specific to reading only the MAC addresses I want (and ignore the rest). In my case, I created a firmware to only accept the MAC addresses of my two sensors, and then push that data to Home Assistant.

The following YouTube video was incredibly useful for assisting in putting this together: https://www.youtube.com/watch?v=RtJpx8BZvMw

Once the ESP32 was set up, it simply read the temperature and humidity data from the two Xiaomi devices, and then reported it back to the Home Assistant. Home Assistant then “sees” 6 incoming sensors, which are being logged on the system, where the data can be put into graphs and monitored over time. The 6 sensors in this case are both Xiaomi devices (“Livingroom” and “Bathroom”) which both monitor three values each; temperature, humidity, battery level. This screen grab was taken from my Home Assistant homepage:

The Home Assistant is clever enough to analyse your network at start-up and see if other devices are connected on your home network that it can use. I discovered and added my Philips Hue lights, so that they can be turned on and off from the dashboard, as well as triggered by other events.

I also discovered my home energy monitoring system, an Engage Efergy Hub, can also be picked up by Home Assistant. With some more tinkering, I was able to include my realtime energy usage, overall energy consumed since the beginning of the year, and a daily energy cost:

Whilst reading online posts about Home Assistant, it became apparent that many other sensors can be added, or additional data could be imported from elsewhere. That’s when my uRADmonitor popped into my mind. If I use an internet browser and look at my local uRAD Model 3 monitor, it outputs it’s sensor data in JSON format. This data can be separated out and imported into Home Assistant as separate sensor readings. So this is exactly what I did:

For those interested in adding your uRADmonitor to your Home Assistant, this is what I did:

Firstly, I identified the IP address of my uRADmonitor by looking at what devices were attached to my home router. Let’s take “192.168.1.15” as an example. I then accessed the Home Assistant files by enabling the “SAMBA add-on” from within Home Assistant, and accessing the “/config/configuration.yaml” file via my computer. The JSON data for the uRADmonitor is located via the ip address, but also include “/j”, as in the below example. In other words, you’d type into the address bar “192.168.1.15/j”.

Inside the configuration.yaml file, I added the following text to the bottom of the file:

sensor:
  - platform: rest
    resource: 192.168.1.15/j
    name: Outside Temperature
    value_template: '{{ value_json.data.temperature }}'
    unit_of_measurement: "°C"

  - platform: rest
    resource: 192.168.1.15/j
    name: Outside Humidity
    value_template: '{{ value_json.data.humidity }}'
    unit_of_measurement: "%"

In the above example, the “sensor:” line indicates the start of a series of additional sensors for Home Assistant to look for. It is only required once, and all additionally added sensors follow the same format each time. Additional parameters can be added, but these are all that I decided to use for the uRADmonitor. The “platform: rest” indicates a sensor, and Home Assistant identifies it as a RESTful sensor. The “name:” tag simply tells Home Assistant what you want this sensor to be identified as. Then, “resource: 192.168.1.15/j” tells the sensor where to look for the data. The “value_template:” tells the Home Assistant what value from the JSON you want to use. Every sensor entry in the config will have “value_json.data.” in them. The only things that change for each entry are the next word. In the above example I added “temperature”, in order to pull the temperature data from the JSON file. The “unit_of_measurement:” tells Home Assistant what unit to assign when it displays the data.

There was some programming tinkering that took me a while to figure out. The sensor data for “Pressure” is a six-figure result directly from the Model 3. For example, as in the above image, the raw JSON data was “101777”. I had to figure out a way to add a decimal point in the correct place, in order for the data to be logged correctly as “1017.77”. The same issue came from the Radiation reading. The raw JSON data was “15” but the correct logging figure needed to be “0.15”. This was done by adding maths formulas within the sensor set-up.

To add the decimal point for “pressure”, I changed the line:

value_template: '{{ value_json.data.pressure }}'

to

value_template: '{{ ((value_json.data.pressure |float-0)/1000*10)|round(2) }}'

And to put a zero and full stop before the “radiation:” reading, I changed the line:

value_template: '{{ value_json.data.cpm }}'

to

value_template: '{{ ((value_json.data.cpm |float-0)/1000*10)|round(2) }}'

The software is quite powerful and allows additional features such as “zones”, and “automation”, For example, I have set up my home address as a zone, and I can set an automated rule that turns all the lights off if I leave that zone, but only after sunset. I have also set a similar automation rule that will turn on a specific light if I enter the home zone, but only if the sun has already set. By using the Home Assistant iOS App, I am also able to track the mobile phone on a map, and use it’s location to trigger events.

Overall I am pleased with the two days work I have spent tinkering with the Home Assistant software and the ESP32. I now have an operating Home Assistant that I can access from anywhere in the world, and monitor my current sensors.

The next step is to figure out a way to include my Teckin wifi enabled plugs, so they can be turned on and off via the homepage, and include their “per plug” energy monitoring data on my dashboard.