summaryrefslogtreecommitdiff
path: root/examples/toggle_relay.py
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2020-03-09 11:54:37 +0100
committerJan200101 <sentrycraft123@gmail.com>2020-03-09 11:54:37 +0100
commitdc4790c0e945cb26f7f026fff6650595fad09eec (patch)
tree3a4b0da2ddd2d2735a5a500d2d0c3dc6a073ca55 /examples/toggle_relay.py
parent209a0b958f694bd5ad2f0f691bf52893584438bf (diff)
downloadShellyPy-dc4790c0e945cb26f7f026fff6650595fad09eec.tar.gz
ShellyPy-dc4790c0e945cb26f7f026fff6650595fad09eec.zip
Update Readme and change filename of example
The README has been updated to point to the filename of the one and only example as well as word some things correctly and remove the (UNTESTED) next to Shelly 2.5 The filename of the example is a bit misleading its not using any devices with a /light/{index} endpoint and instead talks about a personal setup where a Shelly relay is used on a light switch.
Diffstat (limited to 'examples/toggle_relay.py')
-rw-r--r--examples/toggle_relay.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/toggle_relay.py b/examples/toggle_relay.py
new file mode 100644
index 0000000..a2e10a5
--- /dev/null
+++ b/examples/toggle_relay.py
@@ -0,0 +1,10 @@
+import ShellyPy
+
+# try connecting to the Shelly device under that ip
+device = ShellyPy.Shelly("192.168.0.5")
+# WILL throw an exception if the device is not reachable, gives a bad response or requires a login
+
+device.relay(0, turn=True) # turn the relay at index 0 on
+device.relay(0, turn=False) # same as bove but turn it off
+device.relay(0, turn=True, delay=3) # turn the relay 0 on for 3 seconds then off
+# most shelly devices only have 1 or 2 relays