This project uses a Raspberry Pi 3 as a smart hub for dumb lights.
A more detailed writeup of the project can be found at: https://sweisss.github.io/projects/smarthubfordumblights.html
The only files from this repository that need to actually be cloned to the Raspberry Pi are devices.json and rf_transmit.py. The data from flows_vx.json can be imported to Node-RED via copy and paste. For more information on how to do this, see the official Node-RED documentation.
After importing the flow to Node-RED, be sure to install node-red-contrib-discord 5.0.0 from the Manage palatte.
Replace the "Token" entry value of the Discord node with the token of your bot.
Alternatively, save the token under the name DISCORD_TOKEN at the top of your settings.js file located in /home/raspberry/.node-red.
The line should look like the following:
process.env.DISCORD_TOKEN = '<token>'
After setting up the Discord server, be sure to update the channel ids in devices.json.
To control a smart switch using the eWeLink API:
- Log in to https://web.ewelink.cc/
- Get the bearer token from developer tools
- Right-click anywhere on the web application and select "Inspect"
- Go to the Network tab and refresh the page
- Some of the files, including profile, my-scene, and query, will display the Bearer Token in the Request Headers
- NOTE: The token will refresh after logging in on a different device.
- Add the device id to settings.js with the name
PORCHSWITCH_ID, similar to theDISCORD_TOKEN, and reference it from an environment variable in the "Set HTTP POST headers and body" node. - Add the bearer token to a file named token.txt adjacent to the rf_transmit.py script. Update the file paths in the readToken and writeToken nodes if necessary.
Be sure to update the exec node with the correct location of the python script on your system.