Adjust Plenticore select initialisation (#78873)
parent
9e31cf51cb
commit
988e8bfe7b
|
@ -67,29 +67,26 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
entities = []
|
||||
for select in SELECT_SETTINGS_DATA:
|
||||
if select.module_id not in available_settings_data:
|
||||
for description in SELECT_SETTINGS_DATA:
|
||||
if description.module_id not in available_settings_data:
|
||||
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 = {
|
||||
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:
|
||||
continue
|
||||
entities.append(
|
||||
PlenticoreDataSelect(
|
||||
select_data_update_coordinator,
|
||||
description,
|
||||
entry_id=entry.entry_id,
|
||||
platform_name=entry.title,
|
||||
device_class="kostal_plenticore__battery",
|
||||
module_id=select.module_id,
|
||||
data_id=select.key,
|
||||
name=select.name,
|
||||
current_option="None",
|
||||
options=select.options,
|
||||
is_on=select.is_on,
|
||||
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."""
|
||||
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
entity_description: PlenticoreSelectEntityDescription
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator,
|
||||
coordinator: SelectDataUpdateCoordinator,
|
||||
description: PlenticoreSelectEntityDescription,
|
||||
entry_id: str,
|
||||
platform_name: str,
|
||||
device_class: str | None,
|
||||
module_id: str,
|
||||
data_id: str,
|
||||
name: str | None,
|
||||
current_option: str | None,
|
||||
options: list[str],
|
||||
is_on: str,
|
||||
device_info: DeviceInfo,
|
||||
unique_id: str,
|
||||
) -> None:
|
||||
"""Create a new Select Entity for Plenticore process data."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
self.entry_id = entry_id
|
||||
self.platform_name = platform_name
|
||||
self._attr_device_class = device_class
|
||||
self.module_id = module_id
|
||||
self.data_id = data_id
|
||||
self._attr_options = options
|
||||
self.all_options = options
|
||||
self.module_id = description.module_id
|
||||
self.data_id = description.key
|
||||
self._attr_options = description.options
|
||||
self.all_options = description.options
|
||||
self._attr_current_option = current_option
|
||||
self._is_on = is_on
|
||||
self._is_on = description.is_on
|
||||
self._device_info = device_info
|
||||
self._attr_name = name or DEVICE_DEFAULT_NAME
|
||||
self._attr_unique_id = unique_id
|
||||
self._attr_name = description.name or DEVICE_DEFAULT_NAME
|
||||
self._attr_unique_id = f"{entry_id}_{description.module_id}"
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
|
|
Loading…
Reference in New Issue