Skip to content

Commit

Permalink
Fix status check (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasddn committed Dec 19, 2024
1 parent dd3d9b1 commit d2496b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions custom_components/volvo_cars/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ async def async_press(self) -> None:
self.entity_description.api_command
)

status = result.invoke_status.lower() if result else "<none>"
status = result.invoke_status if result else ""

_LOGGER.debug(
"Command %s result: %s",
self.entity_description.api_command,
status,
)
self._attr_extra_state_attributes[ATTR_LAST_RESULT] = status
self._attr_extra_state_attributes[ATTR_LAST_RESULT] = status.lower()
self._attr_extra_state_attributes[ATTR_API_TIMESTAMP] = datetime.now(
UTC
).isoformat()
Expand Down
6 changes: 3 additions & 3 deletions custom_components/volvo_cars/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ async def _async_handle_command(self, command: str, locked: bool) -> None:
self.async_write_ha_state()

result = await self.coordinator.api.async_execute_command(command)
status = result.invoke_status.lower() if result else "<none>"
status = result.invoke_status if result else ""

_LOGGER.debug("Lock '%s' result: %s", command, status)
self._attr_extra_state_attributes[ATTR_LAST_RESULT] = status
self._attr_extra_state_attributes[ATTR_LAST_RESULT] = status.lower()
self._attr_extra_state_attributes[ATTR_API_TIMESTAMP] = datetime.now(
UTC
).isoformat()

if status not in ("COMPLETED", "DELIVERED"):
if status.upper() not in ("COMPLETED", "DELIVERED"):
self._attr_is_locking = False
self._attr_is_unlocking = False
self.async_write_ha_state()
Expand Down

0 comments on commit d2496b1

Please sign in to comment.