Skip to content

Commit

Permalink
Support new oven (#62)
Browse files Browse the repository at this point in the history
Added support for new oven: W7I HT58 T

Signed-off-by: Adrian Lasota <[email protected]>
Signed-off-by: Adrian Lasota <[email protected]>
  • Loading branch information
adrianlasota authored May 29, 2024
1 parent feed453 commit 79fda82
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ dmypy.json
# Pyre type checker
.pyre/
.vscode

# Pycharm
.idea/
33 changes: 33 additions & 0 deletions tests/data/owned_appliances.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,39 @@
"CATEGORY_NAME": "FabricCare",
"MODEL_NO": "WTW8127LW1",
"REPLENISHMENT_DEVICE_MODEL": null
},
{
"DATA_MODEL_KEY": "DDM_COOKING_BIO_SELF_CLEAN_TOURMALINE_V2",
"CATEGORY_NAME": "Cooking",
"MODEL_NO": "000000000000",
"REPLENISHMENT_DEVICE_MODEL": null,
"IMAGE_PATH": null,
"APPLIANCE_ID": 95842,
"APPLIANCE_MASTER_ID": 491,
"MODEL_SKU_ID": null,
"CREATED_AT": 1715804778000,
"UPDATED_AT": 1715804778000,
"APPLIANCE_NAME": "Oven",
"SAID": "0000000000000",
"NEST_AWAY": 0,
"CYCLE_HANDOFF": 0,
"NEST_THERMOSTAT_ID": 0,
"THERMOSTAT_INFLUENCE_THRESHOLD": null,
"THERMOSTAT_DESIRED_OFFSET": null,
"THERMOSTAT_OFFSET_NEEDED": null,
"DELETE_FLAG": 0,
"DISPLAY_POSITION": null,
"SERIAL": "000000000000",
"LOCATION_ID": 260998,
"MACHINE_ID": null,
"MACHINE_POSITION": 0,
"ISVOICEDEFAULT": 1,
"DEVICE_ID": "aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa",
"IS_ENROLLED": null,
"STATUS": "CLAIMED",
"APPLIANCE_TYPE_ID": null,
"MACHINE_STATUS": null,
"APPLIANCE_MODE": 2
}
]
}
2 changes: 2 additions & 0 deletions tests/test_appliancesmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ async def test_fetch_appliances_with_set_account_id(

# ensure that the washer_dryers list is populated
assert len(am.washer_dryers) == 2
# ensure that the oven list is populated
assert len(am.ovens) == 1

await http_client_mock.close_session()

Expand Down
2 changes: 1 addition & 1 deletion whirlpool/appliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async def disconnect(self):
async def start_event_listener(self):
"""Start the appliance event listener"""
await self.fetch_data()
if self._event_socket != None:
if self._event_socket is not None:
LOGGER.warning("Event socket not None when starting event listener")

self._event_socket = EventSocket(
Expand Down
13 changes: 7 additions & 6 deletions whirlpool/appliancesmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ def _add_appliance(self, appliance: dict[str, Any]) -> None:
if "dryer" in data_model or "washer" in data_model:
self._washer_dryers.append(appliance_data)
return

if (
"cooking_minerva" in data_model
or "cooking_vsi" in data_model
or "cooking_u2" in data_model
):
oven_models = [
"cooking_minerva",
"cooking_vsi",
"cooking_u2",
"ddm_cooking_bio_self_clean_tourmaline_v2",
]
if any(model in data_model for model in oven_models):
self._ovens.append(appliance_data)
return

Expand Down
2 changes: 1 addition & 1 deletion whirlpool/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _get_auth_body(

return auth_data

async def _do_auth(self, refresh_token: str) -> dict[str, str]:
async def _do_auth(self, refresh_token: str | None) -> dict[str, str]:
auth_url = self._backend_selector.oauth_token_url
auth_header = {
"Content-Type": "application/x-www-form-urlencoded",
Expand Down
2 changes: 1 addition & 1 deletion whirlpool/eventsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(
self._said = said
self._msg_listener = msg_listener
self._running = False
self._websocket: aiohttp.ClientWebSocketResponse = None
self._websocket: aiohttp.ClientWebSocketResponse | None = None
self._run_future = None
self._con_up_listener = con_up_listener
self._reconnect_tries = RECONNECT_COUNT
Expand Down
4 changes: 2 additions & 2 deletions whirlpool/oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def get_cavity_state(self, cavity: Cavity = Cavity.Upper):

def get_oven_cavity_exists(self, cavity: Cavity):
cavity_state = self.get_cavity_state(cavity=cavity)
return cavity_state != None and cavity_state != CavityState.NotPresent
return cavity_state is not None and cavity_state != CavityState.NotPresent

# todo: persist the kitchen timer objects in the object
def get_kitchen_timer(self, timer_id=1):
Expand Down Expand Up @@ -306,7 +306,7 @@ async def set_cook(
cavity_prefix
+ ATTR_POSTFIX_SET_OPERATION: COOK_OPERATION_MAP[operation_type],
}
if meat_probe_target_temp != None:
if meat_probe_target_temp is not None:
attrs[cavity_prefix + ATTR_POSTFIX_MEAT_PROBE_TARGET_TEMP] = round(
float(meat_probe_target_temp) * 10
)
Expand Down

0 comments on commit 79fda82

Please sign in to comment.