Going a bit crazy with Home Assistant and Zigbee
Over the past couple of months, I've been playing around with Home Assistant - a self hosted, privacy first, open source home automation package. One of the main appeals of this was the availability of very cheap (£10/each or so) temperature and humidity sensors which run on a small coin cell and are completely wireless. When we first moved into this house, I attempted something similar with a 1-wire bus and three temperature sensors, connected to a Raspberry Pi. Generally they worked quite well, but 1-wire busses can be quite fussy at times and I had quite a few issues which I never got to the bottom of.
Home Assistant support for different technologies has been quite impressive and seems to be able to interface with WiFi, Z-Wave, BLE and Zigbee devices. The appeal of Zigbee over WiFi in particular is the separation offered from the rest of the home network. They do not need IP addresses, and definitely do not need to talk to the outside world over the internet.
Flashing the Zigbee Dongle
Generally, people use some kind of "Zigbee Hub" which links up to devices. Manufacturers of these try to market them as being unique to their line of devices, suggesting their devices will only work with their hub, etc. I decided to use a USB dongle directly from the machine running Home Assistant. I don't really remember what I did but I installed some firmware onto it, blindly following a tutorial :-).
Sensors and Stuff
- Currently I have eight temperature/humidity sensors dotted around the house and garden. I've even put some in some storage boxes to keep an eye on the humidity, letting me know if the silica gel needs to be dried out in the oven. Eventually I'd like to replace the central heating thermostat with a relay, but this hasn't been such a high priority because we rarely use the heating. The sensors I am using are from Sonoff and cost around £10-12 depending on the week.
- Attached to the electricity meter of house is a frient Zigbee electricity meter, which counts the LED flashes on the front of the meter and sends these off to Home Assistant. This meter is designed specifically for 1000imp/kWh, so I had to get my hands a bit dirty, since my meter is 3200imp/kWh. For this I defined a custom sensor template:
- name: "Total Consumption"
unit_of_measurement: "kWh"
state: "{{ (states('sensor.electricity_meter_smartenergy_metering_summation_delivered') | float * 1000/3200 | float / 1000) | round(2) }}"
state_class: total_increasing
device_class: energy
One of the nice things about energy monitoring in Home Assistant is the ability to pull in information about CO2 emissions. We pay for "green electricity" but of course it all comes from the same place, so it's good to keep an eye on this and run larger appliances when carbon neutral production is up. At some point I'd really like to get another one of these and strap it to the front of my gas meter.
- I didn't go too crazy with lighting - I had some fun in my bedroom, where I have three zigbee bulbs. In the morning, these gradually get brighter to simulate sunrise, which I've found quite nice through winter when it's dark until quite late. In the kitchen, I set up an Ikea Zigbee motion sensor, along with their Zigbee lighting strips under the counter. This is quite nice as you walk into the kitchen, and I've also configured them not to come on unless it's cloudy outside, or close to sunset.
- Much like the temperature monitoring, I had a setup for monitoring rain, built out of a bunch of scripts and an inet daemon. My new solution is much nicer, and uses a Zigbee door sensor, replacing the original circuit board and reed switch inside the rain gauge. To turn this into millilitres, I have another custom sensor template:
- name: "Rain"
unit_of_measurement: "mL"
state: "{{ (states('counter.raindrops') | float * 4) }"
state_class: total_increasing
Along with two actions. The first is triggered by the sensor, and increments the raindrop counter by one. This is multiplied by four by the sensor template since on average the bucket tips ever 4mL. The second action resets the counter at the beginning of ever hour.
The End :-)
I'm not sure what else I'd like to add, but for some reason I do enjoy collecting data pointlessly, so perhaps a few more interesting sensors. Indoor CO2 is something I'd like to keep track of in our office/lounge since we spend a lot of time in their working and can find ourselves feeling a bit drowsy at times. I also got a pair of Ikea zigbee sockets, but I don't know what to do with them yet.
Related posts:
Wanting to leave a comment?
Comments and feedback are welcome by email (aaron@nospam-aaronsplace.co.uk).