From bad06597c8a59d16ea601644d2ed35e3849c016c Mon Sep 17 00:00:00 2001 From: ollo69 <60491700+ollo69@users.noreply.github.com> Date: Tue, 5 May 2020 21:40:17 +0200 Subject: [PATCH] Skip loading unsupported device - Skip loading unsupported device - Added Washer and Dryer states --- .../smartthinq_sensors/__init__.py | 40 +++++++++++-------- .../smartthinq_sensors/wideq/dryer_states.py | 9 +++++ .../smartthinq_sensors/wideq/washer_states.py | 14 +++++++ 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/custom_components/smartthinq_sensors/__init__.py b/custom_components/smartthinq_sensors/__init__.py index 35d1a436..75566323 100644 --- a/custom_components/smartthinq_sensors/__init__.py +++ b/custom_components/smartthinq_sensors/__init__.py @@ -275,9 +275,11 @@ def device_info(self): return data def init_device(self): - self._device.init_device_info() - self._state = self._device.status - self._model = f"{self._model}-{self._device.model_info.model_type}" + if self._device.init_device_info(): + self._state = self._device.status + self._model = f"{self._model}-{self._device.model_info.model_type}" + return True + return False def _restart_monitor(self): """Restart the device monitor""" @@ -377,29 +379,35 @@ async def lge_devices_setup(hass, client) -> dict: device_name = device.name device_mac = device.macaddress model_name = device.model_name + dev = None + result = False device_count += 1 if device.type == DeviceType.WASHER: - base_name = device_name - dev = LGEDevice(WasherDevice(client, device), base_name) + dev = LGEDevice(WasherDevice(client, device), device_name) elif device.type == DeviceType.DRYER: - base_name = device_name - dev = LGEDevice(DryerDevice(client, device), base_name) + dev = LGEDevice(DryerDevice(client, device), device_name) elif device.type == DeviceType.DISHWASHER: - base_name = device_name - dev = LGEDevice(DishWasherDevice(client, device), base_name) + dev = LGEDevice(DishWasherDevice(client, device), device_name) elif device.type == DeviceType.REFRIGERATOR: - base_name = device_name - dev = LGEDevice(RefrigeratorDevice(client, device), base_name) - else: - _LOGGER.info("Found unsupported LGE Device %s of type %s", device_name, device.type.name) + dev = LGEDevice(RefrigeratorDevice(client, device), device_name) + + if dev: + result = await hass.async_add_executor_job(dev.init_device) + + if not result: + _LOGGER.info( + "Found unsupported LGE Device. Name: %s - Type: %s", + device_name, + device.type.name, + ) continue - await hass.async_add_executor_job(dev.init_device) wrapped_devices.setdefault(device.type, []).append(dev) _LOGGER.info( - "LGE Device added. Name: %s - Model: %s - Mac: %s - ID: %s", - base_name, + "LGE Device added. Name: %s - Type: %s - Model: %s - Mac: %s - ID: %s", + device_name, + device.type.name, model_name, device_mac, device_id, diff --git a/custom_components/smartthinq_sensors/wideq/dryer_states.py b/custom_components/smartthinq_sensors/wideq/dryer_states.py index 57d4db3b..2334e5e5 100644 --- a/custom_components/smartthinq_sensors/wideq/dryer_states.py +++ b/custom_components/smartthinq_sensors/wideq/dryer_states.py @@ -34,7 +34,9 @@ class STATE_DRYER_DRYLEVEL(enum.Enum): MORE = "More" NORMAL = "Normal" SPEED = "Speed" + TURBO = "Turbo" VERY = "Very" + WIND = "Wind" TIME_30 = "30 min" TIME_60 = "60 min" TIME_90 = "90 min" @@ -143,6 +145,13 @@ class STATE_DRYER_ERROR(enum.Enum): "@WM_FL24_TITAN_DRY_90_W": STATE_DRYER_DRYLEVEL.TIME_90, "@WM_FL24_TITAN_DRY_120_W": STATE_DRYER_DRYLEVEL.TIME_120, "@WM_FL24_TITAN_DRY_150_W": STATE_DRYER_DRYLEVEL.TIME_150, + "@WM_MX_OPTION_DRY_TURBO_W": STATE_DRYER_DRYLEVEL.TURBO, + "@WM_MX_OPTION_DRY_WIND_W": STATE_DRYER_DRYLEVEL.WIND, + "@WM_OPTION_DRY_TIME_30_W": STATE_DRYER_DRYLEVEL.TIME_30, + "@WM_OPTION_DRY_TIME_60_W": STATE_DRYER_DRYLEVEL.TIME_60, + "@WM_OPTION_DRY_TIME_90_W": STATE_DRYER_DRYLEVEL.TIME_90, + "@WM_OPTION_DRY_TIME_120_W": STATE_DRYER_DRYLEVEL.TIME_120, + "@WM_OPTION_DRY_TIME_150_W": STATE_DRYER_DRYLEVEL.TIME_150, } DRYERTEMPS = { diff --git a/custom_components/smartthinq_sensors/wideq/washer_states.py b/custom_components/smartthinq_sensors/wideq/washer_states.py index 17a4054b..f9bfbd3c 100644 --- a/custom_components/smartthinq_sensors/wideq/washer_states.py +++ b/custom_components/smartthinq_sensors/wideq/washer_states.py @@ -15,6 +15,7 @@ class STATE_WASHER(enum.Enum): ERROR = "Error" ERRORSTATE = "An error occurred" ERROR_AUTO_OFF = "Automatic Poweroff Error" + FRESHCARE = "FreshCare" FROZEN_PREVENT_INITIAL = "Error during initialization" FROZEN_PREVENT_PAUSE = "System is being unfrozen, you cannot pause this operation." FROZEN_PREVENT_RUNNING = "Unfreezing system, please wait" @@ -36,6 +37,7 @@ class STATE_WASHER_WATERTEMP(enum.Enum): OFF = STATE_OPTIONITEM_NONE NO_SELECT = "Not selected" COLD = "Cold" + ECO_WARM = "Eco Warm" EXTRA_HOT = "Extra Hot" HOT = "Hot" TAP_COLD = "Tap Cold" @@ -106,6 +108,7 @@ class STATE_WASHER_ERROR(enum.Enum): "@WM_STATE_END_W": STATE_WASHER.END, "@WM_STATE_ERROR_W": STATE_WASHER.ERRORSTATE, "@WM_STATE_ERROR_AUTO_OFF_W": STATE_WASHER.ERROR_AUTO_OFF, + "@WM_STATE_FRESHCARE_W": STATE_WASHER.FRESHCARE, "@WM_STATE_FROZEN_PREVENT_INITIAL_W": STATE_WASHER.FROZEN_PREVENT_INITIAL, "@WM_STATE_FROZEN_PREVENT_PAUSE_W": STATE_WASHER.FROZEN_PREVENT_PAUSE, "@WM_STATE_FROZEN_PREVENT_RUNNING_W": STATE_WASHER.FROZEN_PREVENT_RUNNING, @@ -131,6 +134,12 @@ class STATE_WASHER_ERROR(enum.Enum): "@WM_OPTION_TEMP_WARM_W": STATE_WASHER_WATERTEMP.WARM, "@WM_OPTION_TEMP_HOT_W": STATE_WASHER_WATERTEMP.HOT, "@WM_OPTION_TEMP_EXTRA_HOT_W": STATE_WASHER_WATERTEMP.EXTRA_HOT, + "@WM_MX_OPTION_TEMP_COLD_W": STATE_WASHER_WATERTEMP.COLD, + "@WM_MX_OPTION_TEMP_TAP_COLD_W": STATE_WASHER_WATERTEMP.TAP_COLD, + "@WM_MX_OPTION_TEMP_ECO_WARM_W": STATE_WASHER_WATERTEMP.ECO_WARM, + "@WM_MX_OPTION_TEMP_WARM_W": STATE_WASHER_WATERTEMP.WARM, + "@WM_MX_OPTION_TEMP_HOT_W": STATE_WASHER_WATERTEMP.HOT, + "@WM_MX_OPTION_TEMP_EXTRA_HOT_W": STATE_WASHER_WATERTEMP.EXTRA_HOT, "@WM_TITAN2_OPTION_TEMP_COLD_W": STATE_WASHER_WATERTEMP.COLD, "@WM_TITAN2_OPTION_TEMP_20_W": STATE_WASHER_WATERTEMP.TEMP_20, "@WM_TITAN2_OPTION_TEMP_30_W": STATE_WASHER_WATERTEMP.TEMP_30, @@ -155,6 +164,11 @@ class STATE_WASHER_ERROR(enum.Enum): "@WM_OPTION_SPIN_MEDIUM_W": STATE_WASHER_SPINSPEED.SPEED_MEDIUM, "@WM_OPTION_SPIN_HIGH_W": STATE_WASHER_SPINSPEED.SPEED_HIGH, "@WM_OPTION_SPIN_EXTRA_HIGH_W": STATE_WASHER_SPINSPEED.SPEED_EXTRA_HIGH, + "@WM_MX_OPTION_SPIN_NO_SPIN_W": STATE_WASHER_SPINSPEED.NO_SPIN, + "@WM_MX_OPTION_SPIN_LOW_W": STATE_WASHER_SPINSPEED.SPEED_LOW, + "@WM_MX_OPTION_SPIN_MEDIUM_W": STATE_WASHER_SPINSPEED.SPEED_MEDIUM, + "@WM_MX_OPTION_SPIN_HIGH_W": STATE_WASHER_SPINSPEED.SPEED_HIGH, + "@WM_MX_OPTION_SPIN_EXTRA_HIGH_W": STATE_WASHER_SPINSPEED.SPEED_EXTRA_HIGH, "@WM_TITAN2_OPTION_SPIN_NO_SPIN_W": STATE_WASHER_SPINSPEED.NO_SPIN, "@WM_TITAN2_OPTION_SPIN_400_W": STATE_WASHER_SPINSPEED.SPEED_400, "@WM_TITAN2_OPTION_SPIN_600_W": STATE_WASHER_SPINSPEED.SPEED_600,