Skip to content

Commit

Permalink
Exclude removed devices from type overrides
Browse files Browse the repository at this point in the history
fixes #155
  • Loading branch information
jason0x43 committed Jan 21, 2022
1 parent ef30241 commit 77bb059
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions custom_components/hubitat/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""Config flow for Hubitat integration."""
from copy import deepcopy
import logging
from typing import Any, Awaitable, Callable, Dict, List, Optional, Union, cast

from hubitatmaker import (
ConnectionError,
Hub as HubitatHub,
Expand All @@ -11,6 +8,8 @@
RequestError,
)
from hubitatmaker.types import Device
import logging
from typing import Any, Awaitable, Callable, Dict, List, Optional, Union, cast
import voluptuous as vol
from voluptuous.schema_builder import Schema

Expand Down Expand Up @@ -335,15 +334,18 @@ async def _async_step_override_type(

existing_overrides = self.options.get(CONF_DEVICE_TYPE_OVERRIDES)
default_value = []
if existing_overrides:
default_value = [
id for id in existing_overrides if existing_overrides[id] == platform
]

possible_overrides = {
id: devices[id].name for id in devices if matcher(devices[id])
}

if existing_overrides:
default_value = [
id
for id in existing_overrides
if existing_overrides[id] == platform and id in possible_overrides
]

device_schema = vol.Schema(
{
vol.Optional(CONF_DEVICES, default=default_value): cv.multi_select(
Expand Down

0 comments on commit 77bb059

Please sign in to comment.