How to use the aioesphomeapi.model.EntityInfo 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
# ==================== TEXT SENSOR ====================
@attr.s
class TextSensorInfo(EntityInfo):
    icon = attr.ib(type=str, default='')


@attr.s
class TextSensorState(EntityState):
    state = attr.ib(type=str, default='')
    missing_state = attr.ib(type=bool, default=False)


# ==================== CAMERA ====================
@attr.s
class CameraInfo(EntityInfo):
    pass


@attr.s
class CameraState(EntityState):
    image = attr.ib(type=bytes, factory=bytes)


# ==================== CLIMATE ====================
class ClimateMode(enum.IntEnum):
    OFF = 0
    AUTO = 1
    COOL = 2
    HEAT = 3
    FAN_ONLY = 4
    DRY = 5
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
# ==================== BINARY SENSOR ====================
@attr.s
class BinarySensorInfo(EntityInfo):
    device_class = attr.ib(type=str, default='')
    is_status_binary_sensor = attr.ib(type=bool, default=False)


@attr.s
class BinarySensorState(EntityState):
    state = attr.ib(type=bool, default=False)
    missing_state = attr.ib(type=bool, default=False)


# ==================== COVER ====================
@attr.s
class CoverInfo(EntityInfo):
    assumed_state = attr.ib(type=bool, default=False)
    supports_position = attr.ib(type=bool, default=False)
    supports_tilt = attr.ib(type=bool, default=False)
    device_class = attr.ib(type=str, default='')


class LegacyCoverState(enum.IntEnum):
    OPEN = 0
    CLOSED = 1


class LegacyCoverCommand(enum.IntEnum):
    OPEN = 0
    CLOSE = 1
    STOP = 2
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
# ==================== SWITCH ====================
@attr.s
class SwitchInfo(EntityInfo):
    icon = attr.ib(type=str, default='')
    assumed_state = attr.ib(type=bool, default=False)


@attr.s
class SwitchState(EntityState):
    state = attr.ib(type=bool, default=False)


# ==================== TEXT SENSOR ====================
@attr.s
class TextSensorInfo(EntityInfo):
    icon = attr.ib(type=str, default='')


@attr.s
class TextSensorState(EntityState):
    state = attr.ib(type=str, default='')
    missing_state = attr.ib(type=bool, default=False)


# ==================== CAMERA ====================
@attr.s
class CameraInfo(EntityInfo):
    pass


@attr.s
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
@attr.s
class EntityInfo:
    object_id = attr.ib(type=str, default='')
    key = attr.ib(type=int, default=0)
    name = attr.ib(type=str, default='')
    unique_id = attr.ib(type=str, default='')


@attr.s
class EntityState:
    key = attr.ib(type=int, default=0)


# ==================== BINARY SENSOR ====================
@attr.s
class BinarySensorInfo(EntityInfo):
    device_class = attr.ib(type=str, default='')
    is_status_binary_sensor = attr.ib(type=bool, default=False)


@attr.s
class BinarySensorState(EntityState):
    state = attr.ib(type=bool, default=False)
    missing_state = attr.ib(type=bool, default=False)


# ==================== COVER ====================
@attr.s
class CoverInfo(EntityInfo):
    assumed_state = attr.ib(type=bool, default=False)
    supports_position = attr.ib(type=bool, default=False)
    supports_tilt = attr.ib(type=bool, default=False)
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
def _convert_climate_modes(value):
    return [ClimateMode(val) for val in value]


def _convert_climate_fan_modes(value):
    return [ClimateFanMode(val) for val in value]


def _convert_climate_swing_modes(value):
    return [ClimateSwingMode(val) for val in value]


@attr.s
class ClimateInfo(EntityInfo):
    supports_current_temperature = attr.ib(type=bool, default=False)
    supports_two_point_target_temperature = attr.ib(type=bool, default=False)
    supported_modes = attr.ib(type=List[ClimateMode], converter=_convert_climate_modes,
                              factory=list)
    visual_min_temperature = attr.ib(type=float, default=0.0)
    visual_max_temperature = attr.ib(type=float, default=0.0)
    visual_temperature_step = attr.ib(type=float, default=0.0)
    supports_away = attr.ib(type=bool, default=False)
    supports_action = attr.ib(type=bool, default=False)
    supported_fan_modes = attr.ib(
        type=List[ClimateFanMode], converter=_convert_climate_fan_modes, factory=list
    )
    supported_swing_modes = attr.ib(
        type=List[ClimateSwingMode], converter=_convert_climate_swing_modes, factory=list
    )
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
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)


class FanSpeed(enum.IntEnum):
    LOW = 0
    MEDIUM = 1
    HIGH = 2


@attr.s
class FanState(EntityState):
    state = attr.ib(type=bool, default=False)
    oscillating = attr.ib(type=bool, default=False)
    speed = attr.ib(type=FanSpeed, converter=FanSpeed, default=FanSpeed.LOW)
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
class FanSpeed(enum.IntEnum):
    LOW = 0
    MEDIUM = 1
    HIGH = 2


@attr.s
class FanState(EntityState):
    state = attr.ib(type=bool, default=False)
    oscillating = attr.ib(type=bool, default=False)
    speed = attr.ib(type=FanSpeed, converter=FanSpeed, default=FanSpeed.LOW)


# ==================== LIGHT ====================
@attr.s
class LightInfo(EntityInfo):
    supports_brightness = attr.ib(type=bool, default=False)
    supports_rgb = attr.ib(type=bool, default=False)
    supports_white_value = attr.ib(type=bool, default=False)
    supports_color_temperature = attr.ib(type=bool, default=False)
    min_mireds = attr.ib(type=float, default=0.0)
    max_mireds = attr.ib(type=float, default=0.0)
    effects = attr.ib(type=List[str], converter=list, factory=list)


@attr.s
class LightState(EntityState):
    state = attr.ib(type=bool, default=False)
    brightness = attr.ib(type=float, default=0.0)
    red = attr.ib(type=float, default=0.0)
    green = attr.ib(type=float, default=0.0)
    blue = attr.ib(type=float, default=0.0)
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
class SensorInfo(EntityInfo):
    icon = attr.ib(type=str, default='')
    unit_of_measurement = attr.ib(type=str, default='')
    accuracy_decimals = attr.ib(type=int, default=0)
    force_update = attr.ib(type=bool, default=False)


@attr.s
class SensorState(EntityState):
    state = attr.ib(type=float, default=0.0)
    missing_state = attr.ib(type=bool, default=False)


# ==================== SWITCH ====================
@attr.s
class SwitchInfo(EntityInfo):
    icon = attr.ib(type=str, default='')
    assumed_state = attr.ib(type=bool, default=False)


@attr.s
class SwitchState(EntityState):
    state = attr.ib(type=bool, default=False)


# ==================== TEXT SENSOR ====================
@attr.s
class TextSensorInfo(EntityInfo):
    icon = attr.ib(type=str, default='')


@attr.s
github esphome / aioesphomeapi / aioesphomeapi / model.py View on Github external
@attr.s
class LightState(EntityState):
    state = attr.ib(type=bool, default=False)
    brightness = attr.ib(type=float, default=0.0)
    red = attr.ib(type=float, default=0.0)
    green = attr.ib(type=float, default=0.0)
    blue = attr.ib(type=float, default=0.0)
    white = attr.ib(type=float, default=0.0)
    color_temperature = attr.ib(type=float, default=0.0)
    effect = attr.ib(type=str, default='')


# ==================== SENSOR ====================
@attr.s
class SensorInfo(EntityInfo):
    icon = attr.ib(type=str, default='')
    unit_of_measurement = attr.ib(type=str, default='')
    accuracy_decimals = attr.ib(type=int, default=0)
    force_update = attr.ib(type=bool, default=False)


@attr.s
class SensorState(EntityState):
    state = attr.ib(type=float, default=0.0)
    missing_state = attr.ib(type=bool, default=False)


# ==================== SWITCH ====================
@attr.s
class SwitchInfo(EntityInfo):
    icon = attr.ib(type=str, default='')