Home Automation Journey with Home-Assistant.IO and SONOFF
In this tutorial, I would like to share how I can install and configure the Home Assistant with SONOFF for my HDB flat.
Install Home Assistant.IO on Raspberry Pi 4
Follow this guideline https://www.home-assistant.io/installation/raspberrypi to install the Home Assistant with Raspberry Pi 4. Once the installation is successful, go to homeassistant.local:8123 to open the Home Assistant and logon with the user ID and password you have setup.
SONOFF Sensors
I have the temperature and humidity sensor, motion sensor and door window sensor for the start. The sensors are quite cheap and it delivers to your doorstep within a week from the online platform.
Home Assistant Community Store (HACS)
Before we can use and configure the sensors, let’s install the Home Assistant Community Store or HACS.
We need to have the terminal installed on Home Assistant. Go to Supervisor, Add-on Store and search for terminal.
Open Terminal & SSH and install it.
Show terminal in the sidebar menu.
Follow this guide to install the HACS, https://hacs.xyz/docs/installation/installation/
Choose the installation procedure according to your Home Assistant installation type. Go to Configuration and check the Installation Type.
Since my installation type is Home Assistant OS, I will follow this instruction.
wget -q -O — https://install.hacs.xyz | bash -
SonoffLAN
We will be using the SonoffLAN library from https://github.com/AlexxIT/SonoffLAN
Go to HACS and Integrations.
In Integrations tab, click the tripe dot and select Custom repositories.
Enter the URL AlexxIT/SonoffLAN and category Integration and click Add.
Follow the subsequent instructions to install. Once you have successfully installed, you will see the entry below.
Go to File Editor and open /config/configuration.yaml and add this line:
sonoff:
username: your_eWeLink_username
password: your_eWeLink_password
eWeLink — Smart Home
Next is to install the eWeLink Smart Home app on your mobile
https://apps.apple.com/sg/app/ewelink-smart-home/id1035163158
First add the Zigbee RF bridge into your app and pair the sensors with the bridge and add it.
Once you have successfully added, you will see the list of devices under Configuration and Entities.
And now you are ready to assign those sensors to the designated area (e.g. living room, bedroom, bathroom, etc).
Finally we are done with adding and configuring the sensors. The next step is to create automation.
Create Automation
Let’s create a simple automation to turn on the light if the motion is detected with the condition that light will be on only during the specific time.
Click Configuration and Add Automation.
Click Start with an Empty Automation.
Each automation ideally has Triggers, Conditions and Actions.
Give the automation name, KitchenMotion.
Under Triggers, select type State and the entity the one the motion sensor you have added. The trigger will work if the motion has been detected (from off to on).
Under Conditions, select type Time with the window time from 6pm to 7am everyday. If outside this window time, it will not turn on the light.
And finally the Actions is to turn on the light.
That’s all for now. Hope you will be able to realise your home automation without so much hassle and little budget.