Skip to content

Instantly share code, notes, and snippets.

@bactisme
Last active December 2, 2022 21:16
Show Gist options
  • Save bactisme/7936d5cf411bac7ea90540290dadf71f to your computer and use it in GitHub Desktop.
Save bactisme/7936d5cf411bac7ea90540290dadf71f to your computer and use it in GitHub Desktop.
Control Shelly Plug via a simple script
#!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