Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several bugfixes incl production/consumption entities being unavailable #161

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/enphase_envoy/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]

Expand Down
2 changes: 1 addition & 1 deletion custom_components/enphase_envoy/envoy_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 5 additions & 7 deletions custom_components/enphase_envoy/envoy_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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):
"""
Expand Down
Loading