Skip to content

Commit

Permalink
Skip loading unsupported device
Browse files Browse the repository at this point in the history
- Skip loading unsupported device
- Added Washer and Dryer states
  • Loading branch information
ollo69 committed May 5, 2020
1 parent 4010694 commit bad0659
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 16 deletions.
40 changes: 24 additions & 16 deletions custom_components/smartthinq_sensors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions custom_components/smartthinq_sensors/wideq/dryer_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = {
Expand Down
14 changes: 14 additions & 0 deletions custom_components/smartthinq_sensors/wideq/washer_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit bad0659

Please sign in to comment.