Some smart-plugs

This commit is contained in:
Gürkan Gür 2021-12-12 11:55:52 +01:00
parent 1b4ca5594e
commit 3231a11db0
3 changed files with 21 additions and 2 deletions

View File

@ -29,6 +29,10 @@ in
src = ./scripts/workman-toggle;
inherit bash;
});
bulb-toggle = (writeSubbedBin {
name = "bulb-toggle";
src = ./scripts/bulb-toggle;
});
innovpn-toggle = (writeSubbedBin {
name = "innovpn-toggle";
src = ./scripts/innovpn-toggle;

View File

@ -0,0 +1,14 @@
#!/usr/bin/env python3
from sys import argv
from PyP100 import PyP100
p100 = PyP100.P100(argv[1], argv[2], argv[3])
p100.handshake()
p100.login()
if p100.getDeviceInfo()['result']['device_on']:
p100.turnOff()
else:
p100.turnOn()

View File

@ -1,8 +1,9 @@
#!/usr/bin/env bash
target=$1
if [[ $(nmcli con show --active | grep tun0) ]]; then
echo Active, deactivating
nmcli con down VPN-aw
nmcli con down VPN-${target}
else
echo Not active, activating
nmcli con up VPN-aw
nmcli con up VPN-${target}
fi