Initiator: Shelly Timeout
Ressource automatisch nach Leerlaufzeit freigeben mit Shelly
Das folgende Script setzt ein Shelly nach einer Idle-Zeit (wenn der Stromschwellwert länger als TIME_THRESHOLD
Minuten (Standard hardkodiert: 15 Minuten) unterhalb eines Schwellwert POWER_THRESHOLD
(Standard: 0) ist) zurück in die Ausgangslange und führt einen Reset zum Status FREE
durch.
Konfigurierbare Parameter (Reihenfolge ist zu beachten!):
- Host (IP, FQDN)
- Shelly_ID
- Power Treshold (Volt) als Integer (Ganzzahl)
Code: https://gitlab.com/fabinfra/fabaccess/shelly-timeout
Installation
mkdir -p /opt/fabinfra/adapters/
cd /opt/fabinfra/adapters/
git clone https://gitlab.com/fabinfra/fabaccess/initiators/shelly-timeout.git
chmod +x shelly-timeout/main.py
chown -R bffh:bffh /opt/fabinfra/adapters/shelly-timeout/
cd /opt/fabinfra/adapters/shelly-timeout/
python3 -m venv env
. env/bin/activate #activate venv
pip install -r requirements.txt
In FabAccess einbinden
bffh.dhall Snippet
YOUR_INITIATOR_ID =
{
module = "Process",
params =
{
cmd = "/usr/bin/python3",
args = "/opt/fabinfra/adapters/shelly-timeout/main.py 127.0.0.1 shelly1-REDACTED_ID 5",
}
},
Außerdem muss eine init_connection
zu einer Ressource definiert werden, um den Initiator zu verwenden.
Keine Kommentare