From a23f4658731f76a1b68c6b610fb95385d196ac7e Mon Sep 17 00:00:00 2001 From: Vincent Wolsink Date: Thu, 26 Sep 2024 13:12:57 +0200 Subject: [PATCH 1/3] FIX: Configuration dialog not loading --- custom_components/enphase_envoy/config_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/enphase_envoy/config_flow.py b/custom_components/enphase_envoy/config_flow.py index e8340e4..72da669 100644 --- a/custom_components/enphase_envoy/config_flow.py +++ b/custom_components/enphase_envoy/config_flow.py @@ -248,7 +248,7 @@ async def async_step_user(self, user_input=None): } disabled_endpoints = [ ep - for ep in self.config_entry.options.get("disabled_endpoints") + for ep in self.config_entry.options.get("disabled_endpoints", []) if ep in optional_endpoints.keys() ] From bbf9a30382c75a1f31db2378bd49f1060f1da1e2 Mon Sep 17 00:00:00 2001 From: Vincent Wolsink Date: Thu, 26 Sep 2024 13:13:20 +0200 Subject: [PATCH 2/3] Endpoint production_power is an installer endpoint --- custom_components/enphase_envoy/envoy_endpoints.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/enphase_envoy/envoy_endpoints.py b/custom_components/enphase_envoy/envoy_endpoints.py index 5c88294..eebcf47 100644 --- a/custom_components/enphase_envoy/envoy_endpoints.py +++ b/custom_components/enphase_envoy/envoy_endpoints.py @@ -34,7 +34,7 @@ "production_power": { "url": "https://{}/ivp/mod/603980032/mode/power", "cache": 300, - "installer_required": False, + "installer_required": True, "optional": True, }, "pdm_energy": { From 53ae7727b674ba6e7777de5c4b99e715833a03fe Mon Sep 17 00:00:00 2001 From: Vincent Wolsink Date: Thu, 26 Sep 2024 13:14:34 +0200 Subject: [PATCH 3/3] FIX: First endpoint data not stored. FIX: Tries to update first installer endpoint anyway when using owner token --- custom_components/enphase_envoy/envoy_reader.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/custom_components/enphase_envoy/envoy_reader.py b/custom_components/enphase_envoy/envoy_reader.py index 01f4994..250f4fb 100644 --- a/custom_components/enphase_envoy/envoy_reader.py +++ b/custom_components/enphase_envoy/envoy_reader.py @@ -648,7 +648,6 @@ def __init__( self.enlighten_user = enlighten_user self.enlighten_pass = enlighten_pass self.commissioned = commissioned - self.envoy_token_fetch_attempted = False self.enlighten_serial_num = enlighten_serial_num self.token_refresh_buffer_seconds = token_refresh_buffer_seconds self.token_type = None @@ -887,7 +886,6 @@ async def _fetch_envoy_token_json(self): async def _get_enphase_token(self): self._token = await self._fetch_envoy_token_json() - self.envoy_token_fetch_attempted = True _LOGGER.debug("Envoy Token") if self._is_enphase_token_expired(self._token): @@ -947,6 +945,7 @@ def _is_enphase_token_expired(self, token): if decode.get("enphaseUser", None) != None: self.token_type = decode["enphaseUser"] # owner or installer + _LOGGER.debug("TOKEN TYPE: %s", self.token_type) exp_epoch = decode["exp"] # allow a buffer so we can try and grab it sooner @@ -1073,9 +1072,8 @@ async def update_endpoints(self, endpoints=None): _LOGGER.error(f"No settings found for uri {endpoint}") continue - if endpoint_settings.get("installer_required", False) and ( - (self.token_type != "installer" and self.envoy_token_fetch_attempted) - or self.disable_installer_account_use + if endpoint_settings["installer_required"] and ( + self.token_type != "installer" or self.disable_installer_account_use ): _LOGGER.info( "Skipping installer endpoint %s (got token %s and " @@ -1103,8 +1101,8 @@ async def update_endpoints(self, endpoints=None): time.time() - endpoint_settings["last_fetch"], ) - if self.data: - self.data.set_endpoint_data(endpoint, getattr(self, endpoint)) + if self.data: + self.data.set_endpoint_data(endpoint, getattr(self, endpoint)) async def get_data(self, get_inverters=True): """