summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ShellyPy/error.py7
-rw-r--r--ShellyPy/wrapper.py37
-rw-r--r--examples/toggle_lights.py3
3 files changed, 4 insertions, 43 deletions
diff --git a/ShellyPy/error.py b/ShellyPy/error.py
index e595bed..eda4748 100644
--- a/ShellyPy/error.py
+++ b/ShellyPy/error.py
@@ -1,11 +1,4 @@
-class MalformedIP(Exception):
- """
- Exception for malformed IPv4 adresses
- """
- pass
-
-
class BadLogin(Exception):
"""
Exception for bad login details
diff --git a/ShellyPy/wrapper.py b/ShellyPy/wrapper.py
index 2d49f79..25d0056 100644
--- a/ShellyPy/wrapper.py
+++ b/ShellyPy/wrapper.py
@@ -12,34 +12,6 @@ from requests.auth import HTTPBasicAuth
from .error import *
-def confirm_ip(ip):
- """
- @brief Confirm IPv4 adress
-
- @param ip IP given as either a string or List containing strings or integers
-
- @return returns True if ip is valid
- """
-
- if isinstance(ip, str):
- ip = ip.split(".")
- if len(ip) != 4:
- return False
-
- if isinstance(ip, list):
- for value in ip:
- if isinstance(value, str):
- try:
- value = int(value)
- except ValueError:
- value = 256
- if value > 255 or value < 0:
- return False
- return True
-
- return False
-
-
class Shelly:
def __init__(self, ip, port = "80", *args, **kwargs):
@@ -57,9 +29,6 @@ class Shelly:
self.__PROTOCOL__ = "http"
- if not confirm_ip(ip):
- raise MalformedIP("IP is is malformed or not IPv4")
-
login = kwargs.get("login", {})
if isinstance(ip, list):
@@ -95,11 +64,9 @@ class Shelly:
self.__roller__ = status.get("rollers", [])
self.__light__ = status.get("lights", [])
- # documentation for the Shelly Sense is very weird
- # FIXME
+ # FIXME documentation for the Shelly Sense is very weird
self.__ir__ = status.get("ir", [])
- # There isn't even an example of the response for the RGBW
- # FIXME
+ # FIXME There isn't even an example of the response for the RGBW
self.__color__ = status.get("color", [])
self.__emeter__ = status.get("emeter", [])
diff --git a/examples/toggle_lights.py b/examples/toggle_lights.py
index 36c18e9..a2e10a5 100644
--- a/examples/toggle_lights.py
+++ b/examples/toggle_lights.py
@@ -6,4 +6,5 @@ device = ShellyPy.Shelly("192.168.0.5")
device.relay(0, turn=True) # turn the relay at index 0 on
device.relay(0, turn=False) # same as bove but turn it off
-# Shelly 1 devices only have 1 relay
+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