Improve internal naming (#128390)
* Improve internal naming * revert select
This commit is contained in:
parent
a5ecbd547c
commit
11e8e56e05
4 changed files with 16 additions and 18 deletions
|
@ -28,7 +28,7 @@ class AutomowerBinarySensorEntityDescription(BinarySensorEntityDescription):
|
|||
value_fn: Callable[[MowerAttributes], bool]
|
||||
|
||||
|
||||
BINARY_SENSOR_TYPES: tuple[AutomowerBinarySensorEntityDescription, ...] = (
|
||||
MOWER_BINARY_SENSOR_TYPES: tuple[AutomowerBinarySensorEntityDescription, ...] = (
|
||||
AutomowerBinarySensorEntityDescription(
|
||||
key="battery_charging",
|
||||
value_fn=lambda data: data.mower.activity == MowerActivities.CHARGING,
|
||||
|
@ -57,7 +57,7 @@ async def async_setup_entry(
|
|||
async_add_entities(
|
||||
AutomowerBinarySensorEntity(mower_id, coordinator, description)
|
||||
for mower_id in coordinator.data
|
||||
for description in BINARY_SENSOR_TYPES
|
||||
for description in MOWER_BINARY_SENSOR_TYPES
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class AutomowerButtonEntityDescription(ButtonEntityDescription):
|
|||
press_fn: Callable[[AutomowerSession, str], Awaitable[Any]]
|
||||
|
||||
|
||||
BUTTON_TYPES: tuple[AutomowerButtonEntityDescription, ...] = (
|
||||
MOWER_BUTTON_TYPES: tuple[AutomowerButtonEntityDescription, ...] = (
|
||||
AutomowerButtonEntityDescription(
|
||||
key="confirm_error",
|
||||
translation_key="confirm_error",
|
||||
|
@ -73,7 +73,7 @@ async def async_setup_entry(
|
|||
async_add_entities(
|
||||
AutomowerButtonEntity(mower_id, coordinator, description)
|
||||
for mower_id in coordinator.data
|
||||
for description in BUTTON_TYPES
|
||||
for description in MOWER_BUTTON_TYPES
|
||||
if description.exists_fn(coordinator.data[mower_id])
|
||||
)
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class AutomowerNumberEntityDescription(NumberEntityDescription):
|
|||
set_value_fn: Callable[[AutomowerSession, str, float], Awaitable[Any]]
|
||||
|
||||
|
||||
NUMBER_TYPES: tuple[AutomowerNumberEntityDescription, ...] = (
|
||||
MOWER_NUMBER_TYPES: tuple[AutomowerNumberEntityDescription, ...] = (
|
||||
AutomowerNumberEntityDescription(
|
||||
key="cutting_height",
|
||||
translation_key="cutting_height",
|
||||
|
@ -81,7 +81,7 @@ NUMBER_TYPES: tuple[AutomowerNumberEntityDescription, ...] = (
|
|||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class AutomowerWorkAreaNumberEntityDescription(NumberEntityDescription):
|
||||
class WorkAreaNumberEntityDescription(NumberEntityDescription):
|
||||
"""Describes Automower work area number entity."""
|
||||
|
||||
value_fn: Callable[[WorkArea], int]
|
||||
|
@ -91,8 +91,8 @@ class AutomowerWorkAreaNumberEntityDescription(NumberEntityDescription):
|
|||
]
|
||||
|
||||
|
||||
WORK_AREA_NUMBER_TYPES: tuple[AutomowerWorkAreaNumberEntityDescription, ...] = (
|
||||
AutomowerWorkAreaNumberEntityDescription(
|
||||
WORK_AREA_NUMBER_TYPES: tuple[WorkAreaNumberEntityDescription, ...] = (
|
||||
WorkAreaNumberEntityDescription(
|
||||
key="cutting_height_work_area",
|
||||
translation_key_fn=_work_area_translation_key,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
|
@ -117,7 +117,7 @@ async def async_setup_entry(
|
|||
_work_areas = coordinator.data[mower_id].work_areas
|
||||
if _work_areas is not None:
|
||||
entities.extend(
|
||||
AutomowerWorkAreaNumberEntity(
|
||||
WorkAreaNumberEntity(
|
||||
mower_id, coordinator, description, work_area_id
|
||||
)
|
||||
for description in WORK_AREA_NUMBER_TYPES
|
||||
|
@ -126,7 +126,7 @@ async def async_setup_entry(
|
|||
async_remove_work_area_entities(hass, coordinator, entry, mower_id)
|
||||
entities.extend(
|
||||
AutomowerNumberEntity(mower_id, coordinator, description)
|
||||
for description in NUMBER_TYPES
|
||||
for description in MOWER_NUMBER_TYPES
|
||||
if description.exists_fn(coordinator.data[mower_id])
|
||||
)
|
||||
async_add_entities(entities)
|
||||
|
@ -161,16 +161,16 @@ class AutomowerNumberEntity(AutomowerControlEntity, NumberEntity):
|
|||
)
|
||||
|
||||
|
||||
class AutomowerWorkAreaNumberEntity(WorkAreaControlEntity, NumberEntity):
|
||||
"""Defining the AutomowerWorkAreaNumberEntity with AutomowerWorkAreaNumberEntityDescription."""
|
||||
class WorkAreaNumberEntity(WorkAreaControlEntity, NumberEntity):
|
||||
"""Defining the WorkAreaNumberEntity with WorkAreaNumberEntityDescription."""
|
||||
|
||||
entity_description: AutomowerWorkAreaNumberEntityDescription
|
||||
entity_description: WorkAreaNumberEntityDescription
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
mower_id: str,
|
||||
coordinator: AutomowerDataUpdateCoordinator,
|
||||
description: AutomowerWorkAreaNumberEntityDescription,
|
||||
description: WorkAreaNumberEntityDescription,
|
||||
work_area_id: int,
|
||||
) -> None:
|
||||
"""Set up AutomowerNumberEntity."""
|
||||
|
|
|
@ -40,9 +40,7 @@ async def async_setup_entry(
|
|||
_stay_out_zones = coordinator.data[mower_id].stay_out_zones
|
||||
if _stay_out_zones is not None:
|
||||
entities.extend(
|
||||
AutomowerStayOutZoneSwitchEntity(
|
||||
coordinator, mower_id, stay_out_zone_uid
|
||||
)
|
||||
StayOutZoneSwitchEntity(coordinator, mower_id, stay_out_zone_uid)
|
||||
for stay_out_zone_uid in _stay_out_zones.zones
|
||||
)
|
||||
async_remove_entities(hass, coordinator, entry, mower_id)
|
||||
|
@ -86,7 +84,7 @@ class AutomowerScheduleSwitchEntity(AutomowerControlEntity, SwitchEntity):
|
|||
await self.coordinator.api.commands.resume_schedule(self.mower_id)
|
||||
|
||||
|
||||
class AutomowerStayOutZoneSwitchEntity(AutomowerControlEntity, SwitchEntity):
|
||||
class StayOutZoneSwitchEntity(AutomowerControlEntity, SwitchEntity):
|
||||
"""Defining the Automower stay out zone switch."""
|
||||
|
||||
_attr_translation_key = "stay_out_zones"
|
||||
|
|
Loading…
Add table
Reference in a new issue