diff --git a/custom_components/adaptive_lighting/config_flow.py b/custom_components/adaptive_lighting/config_flow.py index 6bf5e430..8fa74f5c 100644 --- a/custom_components/adaptive_lighting/config_flow.py +++ b/custom_components/adaptive_lighting/config_flow.py @@ -84,7 +84,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow): """Handle options flow.""" conf = self.config_entry if conf.source == config_entries.SOURCE_IMPORT: - return self.async_show_form(step_id="init", data_schema={}) + return self.async_show_form(step_id="init", data_schema=None) errors = {} if user_input is not None: validate_options(user_input, errors) diff --git a/custom_components/adaptive_lighting/const.py b/custom_components/adaptive_lighting/const.py index a96e301b..2bd9db96 100644 --- a/custom_components/adaptive_lighting/const.py +++ b/custom_components/adaptive_lighting/const.py @@ -86,11 +86,6 @@ def timedelta_as_int(value): return value.total_seconds() -def join_strings(lst): - """Join a list to comma-separated values string.""" - return ",".join(lst) - - # conf_option: (validator, coerce) tuples # these validators cannot be serialized but can be serialized when coerced by coerce. EXTRA_VALIDATION = { diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 5aa91f7d..0736f7de 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -17,10 +17,6 @@ from typing import Any, Dict, List, Optional, Tuple, Union import astral import voluptuous as vol -from homeassistant.components.homeassistant import ( - DOMAIN as HA_DOMAIN, - SERVICE_UPDATE_ENTITY, -) from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, @@ -158,8 +154,6 @@ def is_our_context(context: Optional[Context]) -> bool: async def handle_apply(switch: AdaptiveSwitch, service_call: ServiceCall): """Handle the entity service apply.""" - if not isinstance(switch, AdaptiveSwitch): - raise ValueError("Apply can only be called for a AdaptiveSwitch.") hass = switch.hass data = service_call.data all_lights = _expand_light_groups(hass, data[CONF_LIGHTS]) @@ -1173,13 +1167,7 @@ class TurnOnOffListener: if light not in self.last_state_change: return False old_states: List[State] = self.last_state_change[light] - await self.hass.services.async_call( - HA_DOMAIN, - SERVICE_UPDATE_ENTITY, - {ATTR_ENTITY_ID: light}, - blocking=True, - context=context, - ) + await self.hass.helpers.entity_component.async_update_entity(light) new_state = self.hass.states.get(light) compare_to = functools.partial( _attributes_have_changed,