This script hosts a simple webserver that periodically pulls data from a Shelly PowerMeter Plug and displays this data.
The webpage later is hosted on port 80 and will look like this:
This script was developed to be run on a Linux container, the following commands are prepared for ```systemd``-based distributions.
The installation process is quite easy:
- Create directories:
mkdir -p /root/SHMonitoring
mkdir -p /var/log/SHMonitoring
- Download
server.py
andSHMonitoring.service
- Move the service file to the correct directory
mv /root/SHMonitoring/SHMonitoring.service /etc/systemd/system
- Edit
server.py
: SetSERVERIP
to the IP on which the webbserver should bind on andSHELLYURL
to the URL of the ShellyPlug that should be monitored. - Install required Python packages:
uvicorn
andfastapi
(either aspython3-uvicorn
andpython3-fastapi
or viapip3 install fastapi uvicorn
) - Enable and start the server
systemctl enable SHMonitoring.service
systemctl start SHMonitoring.service
- Check the current output with
journalctl -r -u SHMonitoring.service