This project implements a SmartHome HTTP Server for managing a smart home based on the deCONZ REST API.
The HTTP Server and Lua libraries are based on the Mako Server, itself an extension of the Barracuda Application Server. Mako is incredibly light, hence the whole application can be run on the most basic Raspberry Pi or equivalent (my setup uses less than 2MB of memory for EVERYTHING).
From the deConz-rest-plugin page:
To communicate with Zigbee devices the RaspBee / RaspBee II Zigbee shield for Raspberry Pi, or a ConBee / ConBee II USB dongle is required.
- Download the Mako Server binary on the Raspberry Pi.
- Checkout the code in this repository.
- Create a
mako.conf
file containing API keys and your location (see example below). - Run
mako -c mako.conf -l::smarthome
. - Open
http://<your-server>:<port>/smarthome/
on a browser.
This assumes you already have a Raspbee/ConBee device running and the smart devices connected via the Phoscon App.
homeio='/home/renato/mako'
sensorsServerUrl = "http://192.168.1.2" -- where deconz API is running
deconzKey='<generated when you start deconz>'
weatherApiKey='<get API key at https://openweathermap.org/>'
latitude=37.2514795 -- location used for weather only
longitude=-116.3766731
The Raspberry Pi needs to run the server as a deamon, so that when you restart it, the server is started up automatically.
To do that, create a systemd service. For example:
## For this file to have any effect, it should be copied as follows:
##
## sudo cp mako.service /etc/systemd/system/mako.service
## sudo chmod 644 /etc/systemd/system/mako.service
##
## Then, start the service with 'sudo systemctl start mako'.
## To make it also start on boot, run 'sudo systemctl enable mako'.
##
## See https://www.linode.com/docs/guides/start-service-at-boot/
##
[Unit]
Description=Smarthome Mako Server
After=network-online.target
[Service]
ExecStart=/home/renato/mako/mako
[Install]
WantedBy=multi-user.target
Now, the server can be monitored as a service:
# check status
$ systemctl status mako
# restart
$ systemctl restart mako
# check the logs
$ journalctl -u mako.service -e -f
I wrote a blog post about coming up with my setup.
Check it out.