aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAndreas Hetz <hetzandreas@gmail.com>2022-11-16 13:13:34 +0100
committerAndreas Hetz <andreas.hetz@hetzengineering.com>2022-11-16 13:13:34 +0100
commitf54bcd4e72fa86c6d11fc90a8b573f3dca24c9eb (patch)
tree6798dabe3de0730624d1bf9e1511f5835d554ee9 /examples
parente78032cf25a571b5eccf86253a3b114ded9ea66d (diff)
downloadShellyPy-f54bcd4e72fa86c6d11fc90a8b573f3dca24c9eb.tar.gz
ShellyPy-f54bcd4e72fa86c6d11fc90a8b573f3dca24c9eb.zip
introduce meter example, add meter information on update function
Diffstat (limited to 'examples')
-rw-r--r--examples/meter.py17
-rw-r--r--examples/toggle_relay.py2
2 files changed, 18 insertions, 1 deletions
diff --git a/examples/meter.py b/examples/meter.py
new file mode 100644
index 0000000..757b4f6
--- /dev/null
+++ b/examples/meter.py
@@ -0,0 +1,17 @@
+import ShellyPy
+
+# try connecting to the Shelly device under that ip
+device = ShellyPy.Shelly("192.168.68.121")
+# WILL throw an exception if the device is not reachable, gives a bad response or requires a login
+
+deviceMeter = device.meter(0) #request meter information
+print(deviceMeter['power']) #print power information
+print(deviceMeter['overpower']) #print overpower information
+print(deviceMeter['is_valid']) #print is_valid information
+print(deviceMeter['timestamp']) #print timestamp information
+print(deviceMeter['counters']) #print counters information
+print(deviceMeter['total']) #print total information
+
+device.update()
+print(device)
+
diff --git a/examples/toggle_relay.py b/examples/toggle_relay.py
index a2e10a5..6b667fe 100644
--- a/examples/toggle_relay.py
+++ b/examples/toggle_relay.py
@@ -5,6 +5,6 @@ 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=False) # same as above 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