Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class LegacyCoverCommand(enum.IntEnum):
OPEN = 0
CLOSE = 1
STOP = 2
class CoverOperation(enum.IntEnum):
IDLE = 0
IS_OPENING = 1
IS_CLOSING = 2
@attr.s
class CoverState(EntityState):
legacy_state = attr.ib(type=LegacyCoverState, converter=LegacyCoverState,
default=LegacyCoverState.OPEN)
position = attr.ib(type=float, default=0.0)
tilt = attr.ib(type=float, default=0.0)
current_operation = attr.ib(type=CoverOperation, converter=CoverOperation,
default=CoverOperation.IDLE)
def is_closed(self, api_version: APIVersion):
if api_version >= APIVersion(1, 1):
return self.position == 0.0
return self.legacy_state == LegacyCoverState.CLOSED
# ==================== FAN ====================
@attr.s
class FanInfo(EntityInfo):
supports_oscillation = attr.ib(type=bool, default=False)
class LegacyCoverCommand(enum.IntEnum):
OPEN = 0
CLOSE = 1
STOP = 2
class CoverOperation(enum.IntEnum):
IDLE = 0
IS_OPENING = 1
IS_CLOSING = 2
@attr.s
class CoverState(EntityState):
legacy_state = attr.ib(type=LegacyCoverState, converter=LegacyCoverState,
default=LegacyCoverState.OPEN)
position = attr.ib(type=float, default=0.0)
tilt = attr.ib(type=float, default=0.0)
current_operation = attr.ib(type=CoverOperation, converter=CoverOperation,
default=CoverOperation.IDLE)
def is_closed(self, api_version: APIVersion):
if api_version >= APIVersion(1, 1):
return self.position == 0.0
return self.legacy_state == LegacyCoverState.CLOSED
# ==================== FAN ====================
@attr.s
class FanInfo(EntityInfo):
supports_oscillation = attr.ib(type=bool, default=False)
supports_speed = attr.ib(type=bool, default=False)
def is_closed(self, api_version: APIVersion):
if api_version >= APIVersion(1, 1):
return self.position == 0.0
return self.legacy_state == LegacyCoverState.CLOSED