How to use the aioesphomeapi.model.LegacyCoverState function in aioesphomeapi

To help you get started, we’ve selected a few aioesphomeapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
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)
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
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)
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
def is_closed(self, api_version: APIVersion):
        if api_version >= APIVersion(1, 1):
            return self.position == 0.0
        return self.legacy_state == LegacyCoverState.CLOSED