Smart lighting applying on a corridor with Home Assistant

Duncan Kwan
4 min readJan 28, 2021

Things used in this project

Hardware components

1. Raspberry Pi 3B+ / Raspberry Pi 4B 2GB x 1

2. Zigbee Coordinator x 1

3. INGENIUM® ZB Universal Dimming Module x 16

4. Zigbee Microwave Sensor x 2

Software apps

1. Home Assistant

Story

Motion sensors are usually applied on some public locations in a building to apply automation for energy saving. In this use case, microwave sensors were installed in a corridor to control the brightness of the lights. If people pass through the corridor, the lights in the zone be will changed to 100%; and 15 seconds later, if there are no motion detect, the lights in the zone will be adjusted to 20%.

This application was fulfilled by using Home Assistants with Zigbee dimmers and microwave sensors. The advantages are

1. Saving the cost of the power line rerouting.

2. There is a dashboard to control and monitor the status of the lighting in the regions.

Setting up the system

Setting up Home Assistant

I followed the instructions found on the Home Assistant website to install Home Assistant. It was simply download the latest version of HASSIO and install it to a 16GB or 32GB SD card with balenaEtcher or Raspberry Pi Imager. After flashing the ROM, insert the SD card to the Raspberry Pi, Power it up and then it will connect to the internet and download the latest version of Home Assistant. This will take about 20 minutes.

Setting up the Zigbee module

I have built a Zigbee coordinator with the same size a Raspberry Pi 0, there is the project page of the Zigbee coordinator with TI CC2538. Please follow the file the instruction on the project page.

After flashing the firmware of the Zigbee coordinator, connect it to the raspberry Pi with USB cable and enable the Zigbee Home Automation on the configuration page on the server.

Pairing Zigbee devices

Go to the path Configuration → Integrations → CONFIGURE button on Zigbee Home Automation.

After entering the page, press ADD DEVICE button on the lower right corner to pair the dimmers and microwave sensors.

Install and setup Node-red

I have used Node-red for the automation. To install Node-RED, clicking Supervisor on the sidebar, and then select Add-on Store. There are many Add-ons for different usages. Then, select Node-RED and install it.

After finishing the installation, we need to configure Node-RED before start it. Hence, go to the Configuration tab and edit the configuration edit box. First, fill in your password on the “credential_secret” row and change the “ssl” row to false and then save it. Next, go back to the info tab and press “start” and you can enter the UI of Node-RED

setup Node-red flow

The flow of the automation is

1. The flow is started by the motion sensor triggering and then brighten the lights to 100% if motions are detected.

2. Check the brightness of each light. If the brightness > 200, the gateway start counting the timer; and if the brightness <=200, the Zigbee coordinator will set the brightness to 100% again until the brightness corrects.

3. After the timer, gateway will check the state of the motion sensor, if there are still any motion detected, the timer restart and check the state again;

4. If there are no motion after the timer, the lights will be dimmed to 20%.

5. Check the brightness of each light. If the brightness >200, the Zigbee coordinator will set the brightness to 20% again until the brightness is corrected.

Summary

After setting up the automation via Node-RED, the Zigbee devices are working well and they are working as expected. People here, the lights go to max. brightness; no people here for a while, lights dim down. They save 230kW in this zone for a month if the usage rate is 50%. So it is a great solution to save energy and for managing and monitoring lighting and usage rate.

--

--

Duncan Kwan

A tech lover and interested in building somethings