Repository: home-assistant/core
File: homeassistant/components/yardian/binary_sensor.py (Python)

Code before:
from .const import DOMAIN
from .coordinator import YardianUpdateCoordinator, YardianZone


@dataclass(kw_only=True, frozen=True)
class YardianBinarySensorEntityDescription(BinarySensorEntityDescription):
    """Entity description for Yardian binary sensors."""

    value_fn: Callable[[YardianUpdateCoordinator], bool | None]


def _zone_enabled_value(
    coordinator: YardianUpdateCoordinator, zone_id: int
) -> bool | None:
    """Return True if zone is enabled on controller."""
    try:
        zone = coordinator.data.zones[zone_id]
    except IndexError:
        return None
    if isinstance(zone, YardianZone):
        return zone.is_enabled
    if isinstance(zone, (tuple, list)):
        zone_seq = cast(Sequence[Any], zone)
        if len(zone_seq) > 1:
            return zone_seq[1] == 1
    return None


def _zone_value_factory(
    zone_id: int,
) -> Callable[[YardianUpdateCoordinator], bool | None]:
    """Return a callable evaluating whether a zone is enabled."""

    def value(coordinator: YardianUpdateCoordinator) -> bool | None:
        return _zone_enabled_value(coordinator, zone_id)

    return value


SENSOR_DESCRIPTIONS: tuple[YardianBinarySensorEntityDescription, ...] = (
    YardianBinarySensorEntityDescription(
        key="watering_running",
        translation_key="watering_running",
        device_class=BinarySensorDeviceClass.RUNNING,
        value_fn=lambda coordinator: bool(coordinator.data.active_zones),
    ),
    YardianBinarySensorEntityDescription(
        key="standby",
        translation_key="standby",
        entity_category=EntityCategory.DIAGNOSTIC,
        value_fn=lambda coordinator: bool(

Review comment (suggestion):
You just updated the code, it literally can't return anything else than a YardianZone, so you can just keep using the old method but then without `[1]` but with `.is_enabled`

Code after:
from .coordinator import YardianUpdateCoordinator


@dataclass(kw_only=True, frozen=True)
class YardianBinarySensorEntityDescription(BinarySensorEntityDescription):
    """Entity description for Yardian binary sensors."""

    value_fn: Callable[[YardianUpdateCoordinator], bool | None]


def _zone_enabled_value(
    coordinator: YardianUpdateCoordinator, zone_id: int
) -> bool | None:
    """Return True if zone is enabled on controller."""
    try:
        return coordinator.data.zones[zone_id].is_enabled
    except IndexError:
        return None


def _zone_value_factory(
    zone_id: int,
) -> Callable[[YardianUpdateCoordinator], bool | None]:
    """Return a callable evaluating whether a zone is enabled."""

    def value(coordinator: YardianUpdateCoordinator) -> bool | None:
        return _zone_enabled_value(coordinator, zone_id)

    return value


SENSOR_DESCRIPTIONS: tuple[YardianBinarySensorEntityDescription, ...] = (
    YardianBinarySensorEntityDescription(
        key="watering_running",
        translation_key="watering_running",
        device_class=BinarySensorDeviceClass.RUNNING,
        value_fn=lambda coordinator: bool(coordinator.data.active_zones),
    ),
    YardianBinarySensorEntityDescription(
        key="standby",
        translation_key="standby",
        entity_category=EntityCategory.DIAGNOSTIC,
        value_fn=lambda coordinator: bool(
            coordinator.data.oper_info.get("iStandby", 0)
        ),
    ),
    YardianBinarySensorEntityDescription(
        key="freeze_prevent",
        translation_key="freeze_prevent",
        device_class=BinarySensorDeviceClass.PROBLEM,
        entity_category=EntityCategory.DIAGNOSTIC,