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.
Enjoy!