Last active
January 16, 2023 02:11
-
-
Save ryanvillarreal/190a2cfa6007d06da20ae580ca4eb001 to your computer and use it in GitHub Desktop.
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
from pyHS100 import Discover,SmartPlug | |
#https://github.com/GadgetReactor/pyHS100 | |
def lamp(): | |
alias = "Office" | |
# discover which device is aliased to office | |
for dev in Discover.discover().values(): | |
if (dev.alias == "Office"): | |
host = dev.host | |
# check to see if the light is off or on - toggle according | |
plug = SmartPlug(host) | |
if (plug.state == "ON"): | |
print("turning off") | |
plug.turn_off() | |
elif(plug.state == "OFF"): | |
print("turning on") | |
plug.turn_on() | |
else: | |
pass | |
if __name__ == "__main__": | |
lamp() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment