Ejemplo n.º 1
0
class BlockNumberDescription(BlockEntityDescription, NumberEntityDescription):
    """Class to describe a BLOCK sensor."""

    mode: NumberMode = NumberMode("slider")
    rest_path: str = ""
    rest_arg: str = ""
Ejemplo n.º 2
0
    rest_arg: str = ""


NUMBERS: Final = {
    ("device", "valvePos"):
    BlockNumberDescription(
        key="device|valvepos",
        icon="mdi:pipe-valve",
        name="Valve Position",
        unit_of_measurement=PERCENTAGE,
        available=lambda block: cast(int, block.valveError) != 1,
        entity_category=EntityCategory.CONFIG,
        min_value=0,
        max_value=100,
        step=1,
        mode=NumberMode("slider"),
        rest_path="thermostat/0",
        rest_arg="pos",
    ),
}


def _build_block_description(entry: RegistryEntry) -> BlockNumberDescription:
    """Build description when restoring block attribute entities."""
    assert entry.capabilities
    return BlockNumberDescription(
        key="",
        name="",
        icon=entry.original_icon,
        unit_of_measurement=entry.unit_of_measurement,
        device_class=entry.original_device_class,