diff --git a/custom_components/adaptive_cover/config_flow.py b/custom_components/adaptive_cover/config_flow.py index 400bf7f..2ae62f8 100644 --- a/custom_components/adaptive_cover/config_flow.py +++ b/custom_components/adaptive_cover/config_flow.py @@ -606,16 +606,15 @@ async def async_step_update(self, user_input: dict[str, Any] | None = None): CONF_MIN_ELEVATION: self.config.get(CONF_MIN_ELEVATION, None), CONF_MAX_ELEVATION: self.config.get(CONF_MAX_ELEVATION, None), CONF_TRANSPARENT_BLIND: self.config.get(CONF_TRANSPARENT_BLIND, False), + CONF_INTERP: self.config.get(CONF_INTERP), CONF_INTERP_START: self.config.get(CONF_INTERP_START, None), CONF_INTERP_END: self.config.get(CONF_INTERP_END, None), CONF_INTERP_LIST: self.config.get(CONF_INTERP_LIST, []), CONF_INTERP_LIST_NEW: self.config.get(CONF_INTERP_LIST_NEW, []), - CONF_INTERP: self.config.get(CONF_INTERP), CONF_LUX_ENTITY: self.config.get(CONF_LUX_ENTITY), CONF_LUX_THRESHOLD: self.config.get(CONF_LUX_THRESHOLD), CONF_IRRADIANCE_ENTITY: self.config.get(CONF_IRRADIANCE_ENTITY), CONF_IRRADIANCE_THRESHOLD: self.config.get(CONF_IRRADIANCE_THRESHOLD), - }, ) @@ -696,6 +695,10 @@ async def async_step_vertical(self, user_input: dict[str, Any] | None = None): }, ) self.options.update(user_input) + if self.options.get(CONF_INTERP, False): + return await self.async_step_interp() + if self.options[CONF_ENABLE_BLIND_SPOT]: + return await self.async_step_blind_spot() if self.options[CONF_CLIMATE_MODE]: return await self.async_step_climate() return await self._update_options() @@ -791,8 +794,11 @@ async def async_step_interp(self, user_input: dict[str, Any] | None = None): ) self.options.update(user_input) return await self._update_options() - return self.add_suggested_values_to_schema( - INTERPOLATION_OPTIONS, user_input or self.options + return self.async_show_form( + step_id="interp", + data_schema=self.add_suggested_values_to_schema( + INTERPOLATION_OPTIONS, user_input or self.options + ), ) async def async_step_blind_spot(self, user_input: dict[str, Any] | None = None): diff --git a/custom_components/adaptive_cover/coordinator.py b/custom_components/adaptive_cover/coordinator.py index a430938..6a70d24 100644 --- a/custom_components/adaptive_cover/coordinator.py +++ b/custom_components/adaptive_cover/coordinator.py @@ -607,16 +607,18 @@ def state(self) -> int: def interpolate_states(self, state): """Interpolate states.""" normal_range = [0, 100] + new_range = [] if self.start_value and self.end_value: new_range = [self.start_value, self.end_value] if self.normal_list and self.new_list: normal_range = list(map(int, self.normal_list)) new_range = list(map(int, self.new_list)) - state = np.interp(state, normal_range, new_range) - if state == new_range[0]: - state = 0 - if state == new_range[-1]: - state = 100 + if new_range: + state = np.interp(state, normal_range, new_range) + if state == new_range[0]: + state = 0 + if state == new_range[-1]: + state = 100 return state @property