mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 08:07:45 +00:00
Adjust Plenticore select initialisation (#78873)
This commit is contained in:
parent
9e31cf51cb
commit
988e8bfe7b
@ -67,29 +67,26 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
for select in SELECT_SETTINGS_DATA:
|
for description in SELECT_SETTINGS_DATA:
|
||||||
if select.module_id not in available_settings_data:
|
if description.module_id not in available_settings_data:
|
||||||
continue
|
continue
|
||||||
needed_data_ids = {data_id for data_id in select.options if data_id != "None"}
|
needed_data_ids = {
|
||||||
|
data_id for data_id in description.options if data_id != "None"
|
||||||
|
}
|
||||||
available_data_ids = {
|
available_data_ids = {
|
||||||
setting.id for setting in available_settings_data[select.module_id]
|
setting.id for setting in available_settings_data[description.module_id]
|
||||||
}
|
}
|
||||||
if not needed_data_ids <= available_data_ids:
|
if not needed_data_ids <= available_data_ids:
|
||||||
continue
|
continue
|
||||||
entities.append(
|
entities.append(
|
||||||
PlenticoreDataSelect(
|
PlenticoreDataSelect(
|
||||||
select_data_update_coordinator,
|
select_data_update_coordinator,
|
||||||
|
description,
|
||||||
entry_id=entry.entry_id,
|
entry_id=entry.entry_id,
|
||||||
platform_name=entry.title,
|
platform_name=entry.title,
|
||||||
device_class="kostal_plenticore__battery",
|
device_class="kostal_plenticore__battery",
|
||||||
module_id=select.module_id,
|
|
||||||
data_id=select.key,
|
|
||||||
name=select.name,
|
|
||||||
current_option="None",
|
current_option="None",
|
||||||
options=select.options,
|
|
||||||
is_on=select.is_on,
|
|
||||||
device_info=plenticore.device_info,
|
device_info=plenticore.device_info,
|
||||||
unique_id=f"{entry.entry_id}_{select.module_id}",
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -100,36 +97,33 @@ class PlenticoreDataSelect(CoordinatorEntity, SelectEntity, ABC):
|
|||||||
"""Representation of a Plenticore Select."""
|
"""Representation of a Plenticore Select."""
|
||||||
|
|
||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
entity_description: PlenticoreSelectEntityDescription
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator,
|
coordinator: SelectDataUpdateCoordinator,
|
||||||
|
description: PlenticoreSelectEntityDescription,
|
||||||
entry_id: str,
|
entry_id: str,
|
||||||
platform_name: str,
|
platform_name: str,
|
||||||
device_class: str | None,
|
device_class: str | None,
|
||||||
module_id: str,
|
|
||||||
data_id: str,
|
|
||||||
name: str | None,
|
|
||||||
current_option: str | None,
|
current_option: str | None,
|
||||||
options: list[str],
|
|
||||||
is_on: str,
|
|
||||||
device_info: DeviceInfo,
|
device_info: DeviceInfo,
|
||||||
unique_id: str,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Create a new Select Entity for Plenticore process data."""
|
"""Create a new Select Entity for Plenticore process data."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
self.entity_description = description
|
||||||
self.entry_id = entry_id
|
self.entry_id = entry_id
|
||||||
self.platform_name = platform_name
|
self.platform_name = platform_name
|
||||||
self._attr_device_class = device_class
|
self._attr_device_class = device_class
|
||||||
self.module_id = module_id
|
self.module_id = description.module_id
|
||||||
self.data_id = data_id
|
self.data_id = description.key
|
||||||
self._attr_options = options
|
self._attr_options = description.options
|
||||||
self.all_options = options
|
self.all_options = description.options
|
||||||
self._attr_current_option = current_option
|
self._attr_current_option = current_option
|
||||||
self._is_on = is_on
|
self._is_on = description.is_on
|
||||||
self._device_info = device_info
|
self._device_info = device_info
|
||||||
self._attr_name = name or DEVICE_DEFAULT_NAME
|
self._attr_name = description.name or DEVICE_DEFAULT_NAME
|
||||||
self._attr_unique_id = unique_id
|
self._attr_unique_id = f"{entry_id}_{description.module_id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user