1 """Cover entity platform for Tailwind."""
3 from __future__
import annotations
7 from gotailwind
import (
8 TailwindDoorAlreadyInStateError,
9 TailwindDoorDisabledError,
10 TailwindDoorLockedOutError,
11 TailwindDoorOperationCommand,
25 from .const
import DOMAIN, LOGGER
26 from .entity
import TailwindDoorEntity
27 from .typing
import TailwindConfigEntry
32 entry: TailwindConfigEntry,
33 async_add_entities: AddEntitiesCallback,
35 """Set up Tailwind cover based on a config entry."""
38 for door_id
in entry.runtime_data.data.doors
43 """Representation of a Tailwind door binary sensor entity."""
45 _attr_device_class = CoverDeviceClass.GARAGE
46 _attr_is_closing =
False
47 _attr_is_opening =
False
49 _attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
53 """Return if the cover is closed or not."""
55 self.coordinator.data.doors[self.
door_iddoor_id].state == TailwindDoorState.CLOSED
59 """Open the garage door.
61 The Tailwind operating command will await the confirmation of the
62 door being opened before returning.
67 await self.coordinator.tailwind.operate(
68 door=self.coordinator.data.doors[self.
door_iddoor_id],
69 operation=TailwindDoorOperationCommand.OPEN,
71 except TailwindDoorDisabledError
as exc:
73 translation_domain=DOMAIN,
74 translation_key=
"door_disabled",
76 except TailwindDoorLockedOutError
as exc:
78 translation_domain=DOMAIN,
79 translation_key=
"door_locked_out",
81 except TailwindDoorAlreadyInStateError:
82 LOGGER.debug(
"Already in the requested state: %s", self.
entity_identity_id)
83 except TailwindError
as exc:
85 translation_domain=DOMAIN,
86 translation_key=
"communication_error",
93 """Close the garage door.
95 The Tailwind operating command will await the confirmation of the
96 door being closed before returning.
101 await self.coordinator.tailwind.operate(
102 door=self.coordinator.data.doors[self.
door_iddoor_id],
103 operation=TailwindDoorOperationCommand.CLOSE,
105 except TailwindDoorDisabledError
as exc:
107 translation_domain=DOMAIN,
108 translation_key=
"door_disabled",
110 except TailwindDoorLockedOutError
as exc:
112 translation_domain=DOMAIN,
113 translation_key=
"door_locked_out",
115 except TailwindDoorAlreadyInStateError:
116 LOGGER.debug(
"Already in the requested state: %s", self.
entity_identity_id)
117 except TailwindError
as exc:
119 translation_domain=DOMAIN,
120 translation_key=
"communication_error",
None async_close_cover(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None async_write_ha_state(self)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, TailwindConfigEntry entry, AddEntitiesCallback async_add_entities)