I started the Remote Controlled Home Lights project for two reasons: I have wanted to upgrade new feature on the lamp that I had made earlier (it is a combination of wood and 3D printing parts- you will see it later) and to solve problem of controlling light in my kitchen working area (carpenter who made my kitchen put switch on the shelf on the same level where dishes are).
My requirements are that project at first needs to be easy-to-use, quick to build and cheap as well. For a switching power supply, Sonoff fits most of my requirements and the plus is because it comes in a case which has a place for an attachment. Because I have planned to have two switches(in the future I will update this number) I decided to have gateway-node architecture. For me, this is an only solution because I will have one point of access and actually at that point when I planned this, I have already had installed an RPI 3 at my home.
Connect to WolkAbout
Create account on WolkAbout, upload template Sonoff-Switches.json and create device. As output of this action you will get device key & password.
Setup RPI 3
Connect your RPI3 to your WiFi network and ssh
to it. RPI 3 will act as a gateway for controlling two Sonoff switches.
Clone repo on RPI 3
git clone --recurse-submodules https://github.com/srdjanStankovic/Remote-Controlled-Home-Lights.git
Setup Sonoff switches
Repo that you downloaded in previous step consist folder Sonoff-Switch-Control
, navigate to it. All files that you need for controlling, configuring and testing Sonoff switches are inside this folder. Just follow Sonoff-Switch-Control guide.
At the end of this guide you will be able to control switches over console.
Setup & Run script
Navigate back to folder Remote-Controlled-Home-Lights/
. Insert key and password in sonoff-switches.py
file and save changes:
def main():
device = wolk.Device(
key="some-key",
password="some-password",
actuator_references=[SWITCH1_REF, SWITCH2_REF],
)
Run python sonoff-switches.py
in terminal and switches will become connected to WolkAbout. Script works only with Python3!
Add Actuator widgets in order to be able to control it. It will look similar to the picture above.
Deploy as systemctl service
Deploy sonoff-switches.py
file as systemctl service following Method 4: SYSTEMD from THIS guide.
* all steps above are detail described in repo README.
Test and Enjoy
Generally I consumed it mostly over Mobile App, but when I'm on my laptop Web it also worked.
ConclusionNow, I'm able to control my lamp and kitchen working area light over my phone. I rarely use Web, only when I sometimes read on my laptop. Idea is to continue with this project and integrate voice control platform with my RPI 3 or with WolkAbout, and that will be real fun.
Comments