Skip to content

Commit

Permalink
Improve internal naming (home-assistant#128390)
Browse files Browse the repository at this point in the history
* Improve internal naming

* revert select
  • Loading branch information
Thomas55555 authored Oct 14, 2024
1 parent a5ecbd5 commit 11e8e56
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/husqvarna_automower/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)


Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/husqvarna_automower/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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])
)

Expand Down
20 changes: 10 additions & 10 deletions homeassistant/components/husqvarna_automower/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -81,7 +81,7 @@ class AutomowerNumberEntityDescription(NumberEntityDescription):


@dataclass(frozen=True, kw_only=True)
class AutomowerWorkAreaNumberEntityDescription(NumberEntityDescription):
class WorkAreaNumberEntityDescription(NumberEntityDescription):
"""Describes Automower work area number entity."""

value_fn: Callable[[WorkArea], int]
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -161,16 +161,16 @@ async def async_set_native_value(self, value: float) -> None:
)


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."""
Expand Down
6 changes: 2 additions & 4 deletions homeassistant/components/husqvarna_automower/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -86,7 +84,7 @@ async def async_turn_on(self, **kwargs: Any) -> None:
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"
Expand Down

0 comments on commit 11e8e56

Please sign in to comment.