- Ubuntu 20.04 (64-bit): https://ubuntu.com/download/desktop
- Anaconda: https://www.anaconda.com/products/individual
conda create -n SmartPlugAutomate python=3.8
conda activate SmartPlugAutomate
cd /home/david
git clone https://github.com/niftimus/SmartPlugAutomate.git
cd /home/david/SmartPlugAutomate
pip install -r requirements.txt
Edit the file config/smartplug-car.json
- Ensure plug_address points to the IP of the TP-Link smartplug (e.g. 10.1.2.13)
- Ensure solar_monitor_url points to the URL of the Enphase monitor endpoint (e.g. http://10.1.2.3/production.json)
- Set min_power is set to the expected energy consumption of the connected device
- Set min_off to the minimum number of seconds to remain off (grace period)
- Set min_on to the minimum number of seconds to remain on (grace period)
- Set check_interval to the number of seconds for each check interval
- Set web_port to the port number of the UI interface
Create a file as root /etc/systemd/system/smartplug-car.service (replace home directory as required):
[Unit]
Description=SmartPlug charger (car) service
[Service]
User=david
# Set the working directory
WorkingDirectory=/home/david/SmartPlugAutomate
# Set the path to the script
ExecStart=/home/david/SmartPlugAutomate/go.sh --config config/smartplug-car.json
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Set the service to run automatically on startup:
sudo systemctl enable smartplug-car.service
Start the service:
sudo service smartplug-car start
Check that the service is running:
sudo service smartplug-car status
smartplug-car.service - Smartplug charger (car) service
Loaded: loaded (/etc/systemd/system/smartplug-car.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-09-24 20:44:39 AEST; 3 weeks 3 days ago
Main PID: 935 (go.sh)
Tasks: 3 (limit: 4573)
CGroup: /system.slice/smartplug-car.service
├─ 935 /bin/bash /home/david/SmartPlugAutomate/go.sh --config config/smartplug-car.jso
└─1235 python smartcontrol.py --config config/smartplug-car.json
Log in to the web UI:
http://0.0.0.0:8001
The web UI should display with the latest plug status. Note: This UI will be available to other devices on the network.