If you’ve been keeping up with my #SmartHome series (and if you haven’t, why not?) you’ll already know that I have plans to make more of my home “smart” using Home Assistant as the software that ties everything together, and some DIY NodeMCU-based hardware that I’m going to build myself as a learning opportunity.
Another important piece of the puzzle, but one that I haven’t previously mentioned, is MQTT.
MQTT is “a publish-subscribe-based lightweight messaging protocol for use on top of the TCP/IP protocol,” at least according the slightly suspect grammar of the person that wrote the Wikipedia article about it.
I learned about MQTT at the same time I learned about Home Assistant, although I didn’t initially appreciate its power. I’ve been using it from the start to enable Home Assistant to know where we are: our phones run an app called OwnTracks which publishes location data to an MQTT “broker” (server). Home Assistant subscribes to these updates, which means it immediately knows about it when our location changes.
I love this whole solution, not least because it’s very easy to run my own MQTT broker (I’m running Mosquitto in a Docker container on my home server) and I’m therefore entirely in control of our location data – it’s not being shared with the developer of some app or service I have no insight into.
This publish/subscribe model and the lightweight nature of MQTT makes it perfect for “Internet of Things” (IoT) devices to communicate with each other, and when you add Home Assistant into the mix it gives me all the tools I need for any sensors I build to feed their data into my smart home ecosystem, and for my smart home controller to feed commands to any devices.
Indeed, I’ve already built my first little NodeMCU app that leverages the technology.
I’ve ordered almost all the components I need for my upcoming hardware projects from China, and they’re only just starting to arrive. Happily the NodeMCUs themselves were amongst the first shipments to land on my doorstep, so even though the only thing I can really do with them right now is programmatically turn their internal LED on and off, I have still been able to use this to start learning: I’ve made it an internet controlled LED.
As promised, I’m going to be sharing both the hardware and the software as I take this DIY Smart Home journey. There is no DIY hardware here, just the NodeMCU itself, but I’ve published both the Arduino sketch and Home Assistant configuration I’ve used for the video.