Home Automation with AngularJS and MQTT on a Raspberry Pi
Simple Home Automation solution with MQTT
Install and start a MQTT Broker with Websocket Support, e.g.
Clone the repository and install the dependencies with NPM
git clone https://github.com/denschu/homepi
cd homepi
sudo npm install -g cordova ionic gulp
npm install
gulp install
Example configuration:
{
"id" : "ceiling_light",
"type" : "on_off",
"value" : false,
"name" : "Ceiling Light",
"topic" : "denschu/home/devices/livingroom/ceiling_light/value"
}
cd www
python -m SimpleHTTPServer 8080
mosca --http-port 8000 --http-bundle --verbose | bunyan
Open http://localhost:8080 in a webbrowser and provide your credentials to connect to the MQTT Broker.
sudo npm install -g cordova ionic
ionic platform add ios
ionic build ios
ionic emulate ios
docker run -p 1883:1883 -p 8000:8000 -v /var/db/mosca:/db denschu/mosca-secure
docker run -d -p 80:80 denschu/homepi
When you create the above device configuration for the GUI then you always define the topics it will subscribe to.
<username>/home/devices/<room>/<device-name>/value
denschu/home/devices/living_room/light1/value
The GUI application will always add a "/set" to the topicname from above when it publishes a message. The payload of the message contains the value to set on the device.
<username>/home/devices/<room>/<device-name>/value/set <value>
denschu/home/devices/living_room/light1/value/set true
Take a look at my puppet manifests to setup the Raspberry Pi very easily with puppet. You also get some help for the manual setup.
At the moment the following "experimental" MQTT bindings are available:
For further informations please refer to my blog posts: