From 5c8d2eac6d337c1d4c57fd3149d975dd59797707 Mon Sep 17 00:00:00 2001 From: Jack Simbach Date: Mon, 4 Jan 2021 13:42:17 -0500 Subject: [PATCH] - changed to not reset appliance apis --- ge_kitchen/devices/base.py | 4 ++++ ge_kitchen/update_coordinator.py | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ge_kitchen/devices/base.py b/ge_kitchen/devices/base.py index a0bf107..eea90ac 100644 --- a/ge_kitchen/devices/base.py +++ b/ge_kitchen/devices/base.py @@ -45,6 +45,10 @@ class ApplianceApi: def appliance(self) -> GeAppliance: return self._appliance + @appliance.setter + def appliance(self, value: GeAppliance): + self._appliance = value + @property def available(self) -> bool: #Note - online will be there since we're using the GE coordinator diff --git a/ge_kitchen/update_coordinator.py b/ge_kitchen/update_coordinator.py index 3c60c34..3bece65 100644 --- a/ge_kitchen/update_coordinator.py +++ b/ge_kitchen/update_coordinator.py @@ -47,13 +47,18 @@ class GeKitchenUpdateCoordinator(DataUpdateCoordinator): self._config_entry = config_entry self._username = config_entry.data[CONF_USERNAME] self._password = config_entry.data[CONF_PASSWORD] + self._appliance_apis = {} # type: Dict[str, ApplianceApi] + self._reset_initialization() super().__init__(hass, _LOGGER, name=DOMAIN) def _reset_initialization(self): self.client = None # type: Optional[GeWebsocketClient] - self._appliance_apis = {} # type: Dict[str, ApplianceApi] + + # Mark all appliances as not initialized yet + for a in self.appliance_apis.values(): + a.appliance.initialized = False # Some record keeping to let us know when we can start generating entities self._got_roster = False @@ -117,6 +122,10 @@ class GeKitchenUpdateCoordinator(DataUpdateCoordinator): api = self._get_appliance_api(appliance) api.build_entities_list() self.appliance_apis[mac_addr] = api + else: + #if we already have the API, switch out its appliance reference for this one + api = self.appliance_apis[mac_addr] + api.appliance = appliance async def get_client(self) -> GeWebsocketClient: """Get a new GE Websocket client."""