aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2020-11-02 19:50:59 +0100
committerJan200101 <sentrycraft123@gmail.com>2020-11-02 19:50:59 +0100
commite7576f96f1893848fc7efd609a0f8fa4038931b3 (patch)
tree811650fcc119cd1d356972f0d32a5d54741797f4
parent0debecc408c68b76703d62702c0cf6832899fef9 (diff)
downloadShellyPy-e7576f96f1893848fc7efd609a0f8fa4038931b3.tar.gz
ShellyPy-e7576f96f1893848fc7efd609a0f8fa4038931b3.zip
improve fetching internals for some shelly devices
-rw-r--r--ShellyPy/wrapper.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/ShellyPy/wrapper.py b/ShellyPy/wrapper.py
index 0454be2..2415063 100644
--- a/ShellyPy/wrapper.py
+++ b/ShellyPy/wrapper.py
@@ -9,7 +9,7 @@ else:
from requests import post
from requests.auth import HTTPBasicAuth
-from .error import *
+import error
class Shelly:
@@ -92,16 +92,15 @@ class Shelly:
self.__type__ = status['device']['type']
self.__name__ = status['device']['hostname']
- self.__relay__ = status.get("relays", [])
- self.__roller__ = status.get("rollers", [])
- self.__light__ = status.get("lights", [])
+ # Settings are already fetched to get device information might as well put the list of things the device has somewhere
+ self.relays = status.get("relays", [])
+ self.rollers = status.get("rollers", [])
+ # RGBW reuses the same lights array
+ self.lights = status.get("lights", [])
- # FIXME documentation for the Shelly Sense is very weird
- self.__ir__ = status.get("ir", [])
- # FIXME There isn't even an example of the response for the RGBW
- self.__color__ = status.get("color", [])
+ self.irs = status.get("light_sensor", None)
- self.__emeter__ = status.get("emeter", [])
+ self.emeters = status.get("emeter", [])
def post(self, page, values = None):
"""
@@ -127,14 +126,14 @@ class Shelly:
timeout=self.__timeout__)
if response.status_code == 401:
- raise BadLogin()
+ raise error.BadLogin()
elif response.status_code == 404:
- raise NotFound("Not Found")
+ raise error.NotFound("Not Found")
try:
return response.json()
except JSONDecodeError:
- raise BadResponse("Bad JSON")
+ raise error.BadResponse("Bad JSON")
def status(self):
"""