Last active
December 2, 2022 21:16
-
-
Save bactisme/7936d5cf411bac7ea90540290dadf71f to your computer and use it in GitHub Desktop.
Control Shelly Plug via a simple script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/python | |
import ShellyPy | |
import sys | |
from pprint import pprint | |
if len(sys.argv) != 3: | |
print("Syntax: [IP] [on/off]\nExample : python3.9 main.py 192.168.1.100 on") | |
sys.exit(0) | |
IP = sys.argv[1] | |
TURN=True | |
if sys.argv[2] == "Off" or sys.argv[2] == "OFF" or sys.argv[2] == "off": | |
TURN=False | |
try: | |
device = ShellyPy.Shelly(IP) | |
device.relay(0, turn=TURN) | |
except Exception as e: | |
print("Error" + str(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment