mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Fix Tailwind cover exception when door is already in the requested state (#124543)
This commit is contained in:
parent
41b3eb9f79
commit
507492947a
@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
from typing import Any
|
||||
|
||||
from gotailwind import (
|
||||
TailwindDoorAlreadyInStateError,
|
||||
TailwindDoorDisabledError,
|
||||
TailwindDoorLockedOutError,
|
||||
TailwindDoorOperationCommand,
|
||||
@ -21,7 +22,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from .const import DOMAIN, LOGGER
|
||||
from .entity import TailwindDoorEntity
|
||||
from .typing import TailwindConfigEntry
|
||||
|
||||
@ -77,6 +78,8 @@ class TailwindDoorCoverEntity(TailwindDoorEntity, CoverEntity):
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="door_locked_out",
|
||||
) from exc
|
||||
except TailwindDoorAlreadyInStateError:
|
||||
LOGGER.debug("Already in the requested state: %s", self.entity_id)
|
||||
except TailwindError as exc:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
@ -109,6 +112,8 @@ class TailwindDoorCoverEntity(TailwindDoorEntity, CoverEntity):
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="door_locked_out",
|
||||
) from exc
|
||||
except TailwindDoorAlreadyInStateError:
|
||||
LOGGER.debug("Already in the requested state: %s", self.entity_id)
|
||||
except TailwindError as exc:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
|
@ -3,6 +3,7 @@
|
||||
from unittest.mock import ANY, MagicMock
|
||||
|
||||
from gotailwind import (
|
||||
TailwindDoorAlreadyInStateError,
|
||||
TailwindDoorDisabledError,
|
||||
TailwindDoorLockedOutError,
|
||||
TailwindDoorOperationCommand,
|
||||
@ -181,3 +182,28 @@ async def test_cover_operations(
|
||||
)
|
||||
assert excinfo.value.translation_domain == DOMAIN
|
||||
assert excinfo.value.translation_key == "communication_error"
|
||||
|
||||
# Test door already in state
|
||||
mock_tailwind.operate.side_effect = TailwindDoorAlreadyInStateError(
|
||||
"Door is already in the requested state"
|
||||
)
|
||||
|
||||
# This call should not raise an exception
|
||||
await hass.services.async_call(
|
||||
COVER_DOMAIN,
|
||||
SERVICE_OPEN_COVER,
|
||||
{
|
||||
ATTR_ENTITY_ID: "cover.door_1",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
# This call should not raise an exception
|
||||
await hass.services.async_call(
|
||||
COVER_DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{
|
||||
ATTR_ENTITY_ID: "cover.door_1",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user