Student: Frâncu Andrei
Video: Demo
Project archive: Automation Scripts
The main objective of this project is the implementation of a home assistant based on MQTT. The main hardware component is the Raspberry Pi board which will host the Home Assistant server along with the Mosquitto broker and will run the Zigbee2MQTT gateway application and the automation scripts. The principal features are the automation of smart plugs to turn on/off at the desired hours, a wake-up light using smart lights and different environment presets to set the desired light and music (ex. workout, party, study). All smart devices can also be controlled manually from the Home Assistant web server or mobile application.
Eclipse Mosquitto is an open source message broker that implements the MQTT protocol. The role of the broker is to route the published messages to the subscribed clients.
Home Assistant is an MQTT supervisor. It offers a visual interface for the state of the integrated smart devices and updates it accordingly, when a message is published on the corresponding topic. All the devices can be grouped and accessed through a customizable dashboard. The Home Assistant software also allows the users to create automations using the application. In this project, HA is only used as a visual interface and to activate the different environment presets.
The widgets that Home Assistant offers to customize your dashboard are called cards. Each card can have one or more devices attached to it. To activate the environment presets, I created a virtual switch device that publishes an MQTT message on a given topic when toggled and attached this entity to a button card.
mqtt: switch: - command_topic: "mode/party/set" state_topic: "mode/party/set" unique_id: party_switch payload_on: "ON" payload_off: "OFF" state_on: "ON" state_off: "OFF"
Zigbee2MQTT is a nodejs Gateway application that connects Zigbee networks to MQTT networks. It allows the usage of a single unified bridge for all the connected Zigbee devices instead of each vendor's bridge. It currently supports 2640 devices from 351 different vendors.
Eclipse Paho MQTT is a Python library that provides a client class which allows the user to connect to a broker and publish and subscribe on different topics. In this project I've used paho-mqtt to implement all my automation scripts:
# m h dom mon dow command 30 21 * * * python3 /home/andrei-francu/turn_off_prize_plante.py 40 6 * * * python3 /home/andrei-francu/turn_on_prize_plante.py 45 6 * * * python3 /home/andrei-francu/wup_light_script.py
During the elaboration of this project I've encountered some challenges:
In conclusion, even though I could not implement a fully functional radio, I feel that I created a useful system that will be an integral part of my home. We've long struggled with waking-up early in the winter and it was always an issue to close the plant lights when we were gone for a longer period of time, so this might be the end of those problems.