From c696489de2f281634b9be2f00913b3716b495d48 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 3 Apr 2018 10:40:38 -0400 Subject: [PATCH] Fetch device type --- example.py | 2 +- wideq.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/example.py b/example.py index feec2bf..7ecb343 100644 --- a/example.py +++ b/example.py @@ -23,7 +23,7 @@ def ls(client): """List the user's devices.""" for device in client.devices: - print('{0.id}: {0.name} ({0.model_id})'.format(device)) + print('{0.id}: {0.name} ({0.type.name} {0.model_id})'.format(device)) def mon(client, device_id): diff --git a/wideq.py b/wideq.py index b42d3af..ddbf796 100644 --- a/wideq.py +++ b/wideq.py @@ -515,6 +515,36 @@ class Client(object): return ModelInfo(self._model_info[url]) +class DeviceType(enum.Enum): + """The category of device.""" + + REFRIGERATOR = 101 + KIMCHI_REFRIGERATOR = 102 + WATER_PURIFIER = 103 + WASHER = 201 + DRYER = 202 + STYLER = 203 + DISHWASHER = 204 + OVEN = 301 + MICROWAVE = 302 + COOKTOP = 303 + HOOD = 304 + AC = 401 # Includes heat pumps, etc., possibly all HVAC devices. + AIR_PURIFIER = 402 + DEHUMIDIFIER = 403 + ROBOT_KING = 501 # Robotic vacuum cleaner? + ARCH = 1001 + MISSG = 3001 + SENSOR = 3002 + SOLAR_SENSOR = 3102 + IOT_LIGHTING = 3003 + IOT_MOTION_SENSOR = 3004 + IOT_SMART_PLUG = 3005 + IOT_DUST_SENSOR = 3006 + EMS_AIR_STATION = 4001 + AIR_SENSOR = 4003 + + class DeviceInfo(object): """Details about a user's device. @@ -540,6 +570,12 @@ class DeviceInfo(object): def name(self): return self.data['alias'] + @property + def type(self): + """The kind of device, as a `DeviceType` value.""" + + return DeviceType(self.data['deviceType']) + def load_model_info(self): """Load JSON data describing the model's capabilities. """