Эх сурвалжийг харах

Fix zlock entry selector: use SelectSelector (multiple) instead of ConfigEntrySelector (single string)

ZiB 4 сар өмнө
parent
commit
61179acb69

+ 6 - 4
custom_components/room_cal_ha/config_flow.py

@@ -10,8 +10,6 @@ from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResu
 from homeassistant.core import callback
 from homeassistant.helpers.aiohttp_client import async_get_clientsession
 from homeassistant.helpers.selector import (
-  ConfigEntrySelector,
-  ConfigEntrySelectorConfig,
   NumberSelector,
   NumberSelectorConfig,
   NumberSelectorMode,
@@ -349,11 +347,15 @@ class RoomCalOptionsFlow(OptionsFlow):
 
     self._pending_options = {**self.config_entry.options}
     opts = self.config_entry.options
+    zlock_options = [
+      {"value": e.entry_id, "label": e.title}
+      for e in self.hass.config_entries.async_entries("zlock_slots")
+    ]
     return self.async_show_form(
       step_id="locks",
       data_schema=vol.Schema({
-        vol.Optional(CONF_ZLOCK_ENTRIES, default=opts.get(CONF_ZLOCK_ENTRIES, [])): ConfigEntrySelector(
-          ConfigEntrySelectorConfig(integration="zlock_slots")
+        vol.Optional(CONF_ZLOCK_ENTRIES, default=opts.get(CONF_ZLOCK_ENTRIES, [])): SelectSelector(
+          SelectSelectorConfig(options=zlock_options, multiple=True)
         ),
         vol.Optional(CONF_ZWAVE_SLOT, default=opts.get(CONF_ZWAVE_SLOT, 1)): NumberSelector(
           NumberSelectorConfig(min=1, max=250, mode=NumberSelectorMode.BOX)