Rename property in Plugwise EntityDescription (#78935)

This commit is contained in:
epenet 2022-09-22 18:55:57 +02:00 committed by GitHub
parent ddf56baf7a
commit 5c7d40cccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,8 +24,8 @@ class PlugwiseSelectDescriptionMixin:
"""Mixin values for Plugwise Select entities."""
command: Callable[[Smile, str, str], Awaitable[Any]]
current_option: str
options: str
current_option_key: str
options_key: str
@dataclass
@ -41,8 +41,8 @@ SELECT_TYPES = (
name="Thermostat schedule",
icon="mdi:calendar-clock",
command=lambda api, loc, opt: api.set_schedule_state(loc, opt, STATE_ON),
current_option="selected_schedule",
options="available_schedules",
current_option_key="selected_schedule",
options_key="available_schedules",
),
PlugwiseSelectEntityDescription(
key="select_regulation_mode",
@ -50,8 +50,8 @@ SELECT_TYPES = (
icon="mdi:hvac",
entity_category=EntityCategory.CONFIG,
command=lambda api, loc, opt: api.set_regulation_mode(opt),
current_option="regulation_mode",
options="regulation_modes",
current_option_key="regulation_mode",
options_key="regulation_modes",
),
)
@ -69,7 +69,10 @@ async def async_setup_entry(
entities: list[PlugwiseSelectEntity] = []
for device_id, device in coordinator.data.devices.items():
for description in SELECT_TYPES:
if description.options in device and len(device[description.options]) > 1:
if (
description.options_key in device
and len(device[description.options_key]) > 1
):
entities.append(
PlugwiseSelectEntity(coordinator, device_id, description)
)
@ -96,12 +99,12 @@ class PlugwiseSelectEntity(PlugwiseEntity, SelectEntity):
@property
def current_option(self) -> str:
"""Return the selected entity option to represent the entity state."""
return self.device[self.entity_description.current_option]
return self.device[self.entity_description.current_option_key]
@property
def options(self) -> list[str]:
"""Return the selectable entity options."""
return self.device[self.entity_description.options]
return self.device[self.entity_description.options_key]
async def async_select_option(self, option: str) -> None:
"""Change to the selected entity option."""