💾 Archived View for midnight.pub › posts › 1252 captured on 2023-04-26 at 13:55:43. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Midnight Pub

Home Automation and Zigbee

~tetris

~tetris sidles up to the bar, holds up two fingers, claps, and watches with a shit-eating grin as all the lights go out~

So I've been dabbling a little in home automation this week.

Ever had to signal your SO by flashing on and off the sofa light because you're stuck outside in the cold since you forgot your keys, and she's not answering the phone?

Until yesterday, this was not something I'd have had to do, but I've crossed this threshold now in the relationship and I expect full retribution sometime later when I'm seemingly home alone.

Current Setup

It started out with me just wanting to know how much energy I was using, and looking for a digital energy reader plug socket. Then I went down a rabbit hole and ended up automating everything.

I've got full control of all of the side lights (i.e. lights that go into a socket), the fridge, the kettle, and have digital thermostats on all but two radiators. These are all Zigbee devices controlled by Home Assistant, running off my Raspberry Pi 4.

Um, Zigbee?

Zigbee

This is a wireless low-energy radio specification that runs in similar frequencies to Wifi, but isn't Wifi. As in, it has no access to the internet and can't actively spy on you by sending telemetry to some suspicious Chinese server.

Zigbee devices form a mesh network with one another, and can ping each other for information via a Zigbee gateway device (again, NOT WiFi). A mesh network allows Device A to talk to Device B, via a path of C, D, and E if A and B are too far away to directly ping each other.

In order to interact with this network, you need a Zigbee gateway device that you can interact with, so for the Raspberry Pi I bought this USB device "SONOFF Zigbee 3.0 USB Dongle Plus, TI CC2652P + CP2102(N)"

Home Assistant

Home Assistant

This is an open source automation software that integrates with a bunch of different wireless or wired devices, offers up their capabilities in a manageable way.

e.g.1 When it's [trigger:Sunny] , [action:switch off] the [device:Front Light], and set the [device:Kitchen Radiator] to [action:18°C].

Home Assistant works with pretty much anything (e.g.2. the battery level on your phone, the GPS coordinates of your car, the amount of energy being supplied by your solar array (one day this dream will be mine....))

Home Assistant works also very well with Zigbee devices, and manages them via a library called ZHA (ZigbeeHomeAutomation).

Is Home Assistant Trust-worthy?

I think so. It's free and open source, but it has a very commercial-ly kind of vibe, which leads me to believe that they might monetize soon in the same way that Owncloud did.

That being said, if you want direct control over your Zigbee devices without giving all the control the Home Assistant, there are some great alternatives:

Zigbee2MQTT and

Mosquitto.

MQTT?

MQTT

Yeah so, Zigbee I think is the mesh protocol that allows devices to connect with one another in a low-power way. MQTT is the actual communication protocol that runs on top of it(?) that creates a "message broker <-> client" relationship, where one of your zigbee devices (the Zigbee Gateway Device) manages the messaging between your Zigbee clients.

Zigbee2MQTT therefore is a piece of software that translates(?) the Zigbee signalling into something compliant with MQTT.

Okay..., and Mosquitto?

Mosquitto is the software that provides a working open source implementation of the MQTT protocol.

The idea then is that instead of the using the ZHA library from Home Assistant, you would put on your tinfoil hat and run Zigbee2MQTT which would feed data into Mosquitto, and then you could control your Zigbee devices via Mosquitto.

Um, why Zigbee2MQTT -> Mosquitto instead of Home Assistant?

Why indeed. Well, for one, you get much more control over your Zigbee devices and their sensors, and can perform over-the-air updates to the firmware of these devices, which ZHA cannot do.

For another, if Home Assistant decide to sell out and start doing something malicious, then there is a good alternative via Zigbee2MQTT.

Zigbee2MQTT also has a fantastic list of supported devices (see above Zigbee2MQTT link) and their capabilities, whilst Home Assistant does not.

Lasting Thoughts

Home Assistant is great. It's simplified and overcomplicated my life in the last few days, and I'm enjoying and hating every minute of it. I'm planning to replace all my actual light switches with Zigbee devices, and also add motion detectors that can act as light triggers, and my own outside temperature controls just coz.

I'm using the current devices flawlessly:

Write a reply

Replies

~johano wrote (thread):

Noswaith dda, ~tetris!

This is an interesting post, and something I've given tiny amounts of thought to in the past... once I got into having a home server and self-hosting things, the next thought was "what else can I tinker around with?" I don't think I'll jump in *just* yet, but if/when I do, what you wrote will be a good reference!

Or who knows, maybe I'll start messing around with software defined radio and revive my younger habit of listening to shortwave broadcasts...

~contrarian wrote (thread):

Home automation IS the future we were promised.