1 """Creates the binary sensor entities for the mower."""
3 from collections.abc
import Callable
4 from dataclasses
import dataclass
6 from typing
import TYPE_CHECKING
8 from aioautomower.model
import MowerActivities, MowerAttributes
12 DOMAIN
as BINARY_SENSOR_DOMAIN,
13 BinarySensorDeviceClass,
15 BinarySensorEntityDescription,
27 from .
import AutomowerConfigEntry
28 from .const
import DOMAIN
29 from .coordinator
import AutomowerDataUpdateCoordinator
30 from .entity
import AutomowerBaseEntity
32 _LOGGER = logging.getLogger(__name__)
36 """Get list of related automations and scripts."""
42 @dataclass(frozen=True, kw_only=True)
44 """Describes Automower binary sensor entity."""
46 value_fn: Callable[[MowerAttributes], bool]
49 MOWER_BINARY_SENSOR_TYPES: tuple[AutomowerBinarySensorEntityDescription, ...] = (
51 key=
"battery_charging",
52 value_fn=
lambda data: data.mower.activity == MowerActivities.CHARGING,
53 device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
57 translation_key=
"leaving_dock",
58 value_fn=
lambda data: data.mower.activity == MowerActivities.LEAVING,
61 key=
"returning_to_dock",
62 translation_key=
"returning_to_dock",
63 value_fn=
lambda data: data.mower.activity == MowerActivities.GOING_HOME,
64 entity_registry_enabled_default=
False,
71 entry: AutomowerConfigEntry,
72 async_add_entities: AddEntitiesCallback,
74 """Set up binary sensor platform."""
75 coordinator = entry.runtime_data
78 for mower_id
in coordinator.data
79 for description
in MOWER_BINARY_SENSOR_TYPES
84 """Defining the Automower Sensors with AutomowerBinarySensorEntityDescription."""
86 entity_description: AutomowerBinarySensorEntityDescription
91 coordinator: AutomowerDataUpdateCoordinator,
92 description: AutomowerBinarySensorEntityDescription,
94 """Set up AutomowerSensors."""
95 super().
__init__(mower_id, coordinator)
101 """Return the state of the binary sensor."""
105 """Raise issue when entity is registered and was not disabled."""
109 entity_id := er.async_get(self.
hasshass).async_get_entity_id(
110 BINARY_SENSOR_DOMAIN, DOMAIN, self.
unique_idunique_id
122 f
"deprecated_entity_{self.entity_description.key}",
123 breaks_in_ha_version=
"2025.6.0",
125 severity=IssueSeverity.WARNING,
126 translation_key=
"deprecated_entity",
127 translation_placeholders={
128 "entity_name":
str(self.
namename),
136 f
"deprecated_task_entity_{self.entity_description.key}",
None async_added_to_hass(self)
None __init__(self, str mower_id, AutomowerDataUpdateCoordinator coordinator, AutomowerBinarySensorEntityDescription description)
MowerAttributes mower_attributes(self)
str|UndefinedType|None name(self)
list[str] automations_with_entity(HomeAssistant hass, str entity_id)
None async_setup_entry(HomeAssistant hass, AutomowerConfigEntry entry, AddEntitiesCallback async_add_entities)
list[str] entity_used_in(HomeAssistant hass, str entity_id)
None async_create_issue(HomeAssistant hass, str entry_id)
None async_delete_issue(HomeAssistant hass, str entry_id)
list[str] scripts_with_entity(HomeAssistant hass, str entity_id)