Skip to content

Commit 47b5e37

Browse files
Merge pull request #161 from vincentwolsink/bugfix_thursday
Several bugfixes incl production/consumption entities being unavailable
2 parents 9a72d75 + 53ae772 commit 47b5e37

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

custom_components/enphase_envoy/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async def async_step_user(self, user_input=None):
248248
}
249249
disabled_endpoints = [
250250
ep
251-
for ep in self.config_entry.options.get("disabled_endpoints")
251+
for ep in self.config_entry.options.get("disabled_endpoints", [])
252252
if ep in optional_endpoints.keys()
253253
]
254254

custom_components/enphase_envoy/envoy_endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"production_power": {
3535
"url": "https://{}/ivp/mod/603980032/mode/power",
3636
"cache": 300,
37-
"installer_required": False,
37+
"installer_required": True,
3838
"optional": True,
3939
},
4040
"pdm_energy": {

custom_components/enphase_envoy/envoy_reader.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ def __init__(
648648
self.enlighten_user = enlighten_user
649649
self.enlighten_pass = enlighten_pass
650650
self.commissioned = commissioned
651-
self.envoy_token_fetch_attempted = False
652651
self.enlighten_serial_num = enlighten_serial_num
653652
self.token_refresh_buffer_seconds = token_refresh_buffer_seconds
654653
self.token_type = None
@@ -887,7 +886,6 @@ async def _fetch_envoy_token_json(self):
887886

888887
async def _get_enphase_token(self):
889888
self._token = await self._fetch_envoy_token_json()
890-
self.envoy_token_fetch_attempted = True
891889

892890
_LOGGER.debug("Envoy Token")
893891
if self._is_enphase_token_expired(self._token):
@@ -947,6 +945,7 @@ def _is_enphase_token_expired(self, token):
947945

948946
if decode.get("enphaseUser", None) != None:
949947
self.token_type = decode["enphaseUser"] # owner or installer
948+
_LOGGER.debug("TOKEN TYPE: %s", self.token_type)
950949

951950
exp_epoch = decode["exp"]
952951
# allow a buffer so we can try and grab it sooner
@@ -1073,9 +1072,8 @@ async def update_endpoints(self, endpoints=None):
10731072
_LOGGER.error(f"No settings found for uri {endpoint}")
10741073
continue
10751074

1076-
if endpoint_settings.get("installer_required", False) and (
1077-
(self.token_type != "installer" and self.envoy_token_fetch_attempted)
1078-
or self.disable_installer_account_use
1075+
if endpoint_settings["installer_required"] and (
1076+
self.token_type != "installer" or self.disable_installer_account_use
10791077
):
10801078
_LOGGER.info(
10811079
"Skipping installer endpoint %s (got token %s and "
@@ -1103,8 +1101,8 @@ async def update_endpoints(self, endpoints=None):
11031101
time.time() - endpoint_settings["last_fetch"],
11041102
)
11051103

1106-
if self.data:
1107-
self.data.set_endpoint_data(endpoint, getattr(self, endpoint))
1104+
if self.data:
1105+
self.data.set_endpoint_data(endpoint, getattr(self, endpoint))
11081106

11091107
async def get_data(self, get_inverters=True):
11101108
"""

0 commit comments

Comments
 (0)