This App exposes an API to controll them via HTTP and integrate them into a Smart Home Solution (e.g. Homeassistant).
- Pi (Zero)
- RF Module connected to the pi
- Executeable to send commands via the RF module
Example .env
PORT=8080
CODESEND_COMMAND=path/to/executeable
!!! This Example is based on my implemenation to Control ZAP 433 Outlets !!!
Add your codes to the codes.json
located in /store/states/codes.json
{
"WallPlug_1":
{
"on": 70963, # on code
"off": 70972 # off code
},
}
Once configured to your needs build the app via yarn build
Add start.sh
to rc.local
to ensure the api gets started once the system is booting.
Get State of "WallPlug_1":
curl --location --request GET 'http://192.168.10.27:8080/v1/state/WallPlug_1'
Turn on "WallPlug_1":
curl --location --request PUT 'http://192.168.10.27:8080/v1/state/WallPlug_1' \
--header 'Content-Type: application/json' \
--data-raw '{ "on": true }'
command_line:
- switch:
name: Outlet 1
unique_id: wallplug_1
command_on: >
curl --location --request PUT "http://<IP>:8080/v1/state/WallPlug_1" --header 'Content-Type: application/json' --data-raw '{ "on": true }'
command_off: >
curl --location --request PUT "http://<IP>:8080/v1/state/WallPlug_1" --header 'Content-Type: application/json' --data-raw '{ "on": false }'
command_state: curl -X GET http://<IP>:8080/v1/state/WallPlug_1
value_template: >
{{ value == "1" }}
sudo apt-get install ufw
sudo ufw allow ssh
sudo ufw allow from <your-home-assistant-host> to any port 8080 proto tcp
sudo ufw enable