Home Automation with Arduino MQTT
I've been working on a few networked projects with Arduino lately as well as looking into combining the various home automation hacks into a more cohesive system. MQTT has kept popping up on my radar for a while now and is perfect for building my centralised home automation system. Basically MQTT is a lightweigt publish/subscribe messaging protocol, every message has a topic and an optional payload.
I have had the Open Source Mosquitto MQTT Broker set up on our server for a while now. Added a basic Python script doing some logic and some Arduino clients using the Arduino MQTT library to send button presses and flash LEDs etc.
As a proof of concept it's working fantastically, but to go further I need some sort of defined schema for home automation using MQTT. I thought I would publish this in the hopes that someone else has thought about this before and has feedback/suggestions/criticism on it.
Below is what I've come up with so far - really just a brain dump. The left side of the = being the topic and the right side being the various payload options (separated by a forward slash or a range shown by a dash). 00:00:00:00:00:00 is an example MAC address of an input or output node. $PERSON represents a unique person id.
/home/all/time = sunrise/sunset /home/all/alarm = security/fire/earthquake/flood
Some meta messages designed to be sent on startup of the node, notifying the server of start and the various inputs or outputs that are available.
/home/00:00:00:00:00:00/meta/start /home/00:00:00:00:00:00/meta/output/0 = digital/fader /home/00:00:00:00:00:00/meta/input/0 = button/motion/light
Some environmental data, temperature etc. The beginnings of prescence to facilitate actions on peoples movements;
/home/00:00:00:00:00:00/event/env/temperature = 18.2 /home/00:00:00:00:00:00/event/env/humidity = 50 /home/00:00:00:00:00:00/event/env/light = 0-100 /home/00:00:00:00:00:00/event/presence/$PERSON = enter/exit
And the guts of it, inputs and outputs, this is the part I'm struggling with the most currently - whether to breakout the events into buttons, motion, timers etc. or stick with just input/output;
/home/00:00:00:00:00:00/input/0 = press/hold/release/motion/no-motion /home/00:00:00:00:00:00/input/0/feedback = ? /home/00:00:00:00:00:00/output/0 = on/off/blink/fade=0-100/timer=10
There's other things to consider, for starters; the input/output id (on the end of the topic) will need to be translated on the node.
If anyone has any suggestions on the general schema, language used, or anything I would welcome it. Please let me know, either in the comments below or by email.