Remote Controlled Home Lights
%%%
#%, %%( %%#
%%( %%* %%%
,%% (% %%
# #%%%%%* ,
#%#........,%%,
%%%%%%%%, %%..............%% #%%%%%%%%
/%................,%
%%....&@*@@@/@#....%.
,%...|..........@..%
*%..#.........(.(%
(%.,......,.,%
%,#......%.%.
%#./.....,.%
/%.%....,..%
%%%%%%%%%%#
%%%%
.,,,
In this project, I connected two Sonoff switches over Raspberry Pi3 to WolkAbout IoT Platform to control light at my home. One Sonoff switch is installed to my lamp in the dining room and another one to background light on the kitchen working area.
Prerequisite
Hardware:
Software:
- Python3 with installed pip. NOTE: scripts and dependencies don’t support Python2!
- Sonoff-Switch-Control python script
- WolkAbout IoT Platform account
- wolk-connect library
Usage
1’st step
Create account on WolkAbout. Upload template Sonoff-Switches.json
from this repo and create device. As output of this action you will get device key & password. Save this, it will be used in step 4.
2’nd step
Clone this repo to RPI with following command:
git clone --recurse-submodules https://github.com/srdjanStankovic/Remote-Controlled-Home-Lights.git
3’rd step
Navigate to path Remote-Controlled-Home-Lights/Sonoff-Switch-Control/
. Then you need to connect, configure and test your both Sonoff switches to your WiFi network following this repo Sonoff-Switch-Control guide. You actually downloaded this repo as submodule and you are navigated on it’s location on your RPI.
4’th step
When you succefully control your Sonoff’s navigate one folder back to Remote-Controlled-Home-Lights/
. Here insert key and password into the_home_gateway.py
file(key and password are given while device is created on WolkAbout- described in 1’st step):
def main():
device = wolk.Device(
key="some-key",
password="some-password",
actuator_references=[SWITCH1_REF, SWITCH2_REF],
)
5’th step
Run python3 the_home_gateway.py
in console and switches will become connected on WolkAbout.
Add Actuator widgets and I become enabled to control it. It looks similar to this:
6’th step (Optional)
At the end I deployed the_home_gateway.py
file as systemctl service following Method 4: SYSTEMD from THIS guide. This is good beacuse service will continue to run in background and even when any kind of reset ocuurs.
Conclusion
Now, I’m able to control my lamp and kitchen light over my phone. Web I used rarely, sometimes when I read on my laptop. Idea is to continue with this project and integrate voice control platform with my RPI or with WolkAbout.