Skip to content

Commit

Permalink
fix: service calls not finding correct config_entry (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 authored Mar 1, 2024
1 parent 3323623 commit 10b200b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions custom_components/openevse/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async def _set_override(self, service: ServiceCall) -> None:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s", config_id)
manager = self.hass.data[DOMAIN][config_id][MANAGER]

Expand Down Expand Up @@ -250,7 +250,7 @@ async def _clear_override(self, service: ServiceCall) -> None:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s Type: %s", config_id, type(config_id))
manager = self.hass.data[DOMAIN][config_id][MANAGER]

Expand All @@ -271,7 +271,7 @@ async def _set_limit(self, service: ServiceCall) -> None:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s", config_id)
manager = self.hass.data[DOMAIN][config_id][MANAGER]

Expand Down Expand Up @@ -305,7 +305,7 @@ async def _clear_limit(self, service: ServiceCall) -> None:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s Type: %s", config_id, type(config_id))
manager = self.hass.data[DOMAIN][config_id][MANAGER]

Expand All @@ -327,13 +327,13 @@ async def _get_limit(self, service: ServiceCall) -> ServiceResponse:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s Type: %s", config_id, type(config_id))
manager = self.hass.data[DOMAIN][config_id][MANAGER]

response = await manager.get_limit()
_LOGGER.debug("Get limit response %s.", response)
return response
return response[0]

async def _make_claim(self, service: ServiceCall) -> None:
"""Make a claim."""
Expand All @@ -349,7 +349,7 @@ async def _make_claim(self, service: ServiceCall) -> None:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s", config_id)
manager = self.hass.data[DOMAIN][config_id][MANAGER]

Expand Down Expand Up @@ -393,7 +393,7 @@ async def _release_claim(self, service: ServiceCall) -> None:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s Type: %s", config_id, type(config_id))
manager = self.hass.data[DOMAIN][config_id][MANAGER]

Expand All @@ -415,13 +415,13 @@ async def _list_claims(self, service: ServiceCall) -> ServiceResponse:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s Type: %s", config_id, type(config_id))
manager = self.hass.data[DOMAIN][config_id][MANAGER]

response = await manager.list_claims()
_LOGGER.debug("List claims response %s.", response)
return response
return response[0]

async def _list_overrides(self, service: ServiceCall) -> ServiceResponse:
"""Get the overrides."""
Expand All @@ -438,10 +438,10 @@ async def _list_overrides(self, service: ServiceCall) -> ServiceResponse:
if not device_entry:
raise ValueError(f"Device ID {device_id} is not valid")

config_id = list(device_entry.config_entries)[0]
config_id = list(device_entry.connections)[0][1]
_LOGGER.debug("Config ID: %s Type: %s", config_id, type(config_id))
manager = self.hass.data[DOMAIN][config_id][MANAGER]

response = await manager.get_override()
_LOGGER.debug("List overrides response %s.", response)
return response
return response[0]

0 comments on commit 10b200b

Please sign in to comment.