Skip to content

Commit 35c1327

Browse files
committed
Fix options flow crash when a device is removed from B-hyve account
Closes #203
1 parent 7ec8678 commit 35c1327

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

custom_components/bhyve/config_flow.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,18 @@ async def async_step_init(
222222
if d.get("type") != DEVICE_BRIDGE
223223
}
224224

225+
# Filter saved defaults to only include devices that still exist,
226+
# in case a device was removed from the B-hyve account.
227+
saved_devices = self.config_entry.options.get(CONF_DEVICES, [])
228+
valid_defaults = [d for d in saved_devices if d in device_options]
229+
225230
return self.async_show_form(
226231
step_id="init",
227232
data_schema=vol.Schema(
228233
{
229234
vol.Required(
230235
CONF_DEVICES,
231-
default=self.config_entry.options.get(CONF_DEVICES),
236+
default=valid_defaults,
232237
): cv.multi_select(device_options),
233238
}
234239
),

0 commit comments

Comments
 (0)