Skip to content

Commit

Permalink
Check for empty list in GetConfiguration response (#1300)
Browse files Browse the repository at this point in the history
Spec seems to allow for empty list in GetConfiguration response
in addition to the list being absent.
  • Loading branch information
malaakso authored Sep 8, 2024
1 parent f2beba8 commit 51ae7a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/ocpp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,15 +894,15 @@ async def get_configuration(self, key: str = ""):
else:
req = call.GetConfiguration(key=[key])
resp = await self.call(req)
if resp.configuration_key is not None:
if resp.configuration_key:
value = resp.configuration_key[0][om.value.value]
_LOGGER.debug("Get Configuration for %s: %s", key, value)
self._metrics[cdet.config_response.value].value = datetime.now(
tz=timezone.utc
)
self._metrics[cdet.config_response.value].extra_attr = {key: value}
return value
if resp.unknown_key is not None:
if resp.unknown_key:
_LOGGER.warning("Get Configuration returned unknown key for: %s", key)
await self.notify_ha(f"Warning: charger reports {key} is unknown")
return None
Expand Down

0 comments on commit 51ae7a9

Please sign in to comment.