From 7615f138d9839abf4456da73629d6757e73abf7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=96berg?= <62830707+droberg@users.noreply.github.com> Date: Tue, 15 Mar 2022 08:26:54 +0100 Subject: [PATCH] Clean up code for onewire config flow (#67970) * Change debug level of integration reload after config update to debug * Remove extra .keys() call for dict itreation * Remove unecessary type check * Remove unused LOGGER reference --- homeassistant/components/onewire/__init__.py | 2 +- .../components/onewire/config_flow.py | 28 ++++++++----------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/onewire/__init__.py b/homeassistant/components/onewire/__init__.py index ceef037bfcc..c6f3d7dfa3f 100644 --- a/homeassistant/components/onewire/__init__.py +++ b/homeassistant/components/onewire/__init__.py @@ -47,5 +47,5 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> async def options_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None: """Handle options update.""" - _LOGGER.info("Configuration options updated, reloading OneWire integration") + _LOGGER.debug("Configuration options updated, reloading OneWire integration") await hass.config_entries.async_reload(entry.entry_id) diff --git a/homeassistant/components/onewire/config_flow.py b/homeassistant/components/onewire/config_flow.py index a7373206666..25604473bcf 100644 --- a/homeassistant/components/onewire/config_flow.py +++ b/homeassistant/components/onewire/config_flow.py @@ -1,7 +1,6 @@ """Config flow for 1-Wire component.""" from __future__ import annotations -import logging from typing import Any import voluptuous as vol @@ -47,9 +46,6 @@ DATA_SCHEMA_MOUNTDIR = vol.Schema( ) -_LOGGER = logging.getLogger(__name__) - - async def validate_input_owserver( hass: HomeAssistant, data: dict[str, Any] ) -> dict[str, str]: @@ -255,7 +251,7 @@ class OnewireOptionsFlowHandler(OptionsFlow): default=self._get_current_configured_sensors(), description="Multiselect with list of devices to choose from", ): cv.multi_select( - {device: False for device in self.configurable_devices.keys()} + {device: False for device in self.configurable_devices} ), } ), @@ -273,18 +269,16 @@ class OnewireOptionsFlowHandler(OptionsFlow): return await self._update_options() self.current_device, description = self.devices_to_configure.popitem() - data_schema: vol.Schema - if description.family == "28": - data_schema = vol.Schema( - { - vol.Required( - OPTION_ENTRY_SENSOR_PRECISION, - default=self._get_current_setting( - description.id, OPTION_ENTRY_SENSOR_PRECISION, "temperature" - ), - ): vol.In(PRECISION_MAPPING_FAMILY_28), - } - ) + data_schema = vol.Schema( + { + vol.Required( + OPTION_ENTRY_SENSOR_PRECISION, + default=self._get_current_setting( + description.id, OPTION_ENTRY_SENSOR_PRECISION, "temperature" + ), + ): vol.In(PRECISION_MAPPING_FAMILY_28), + } + ) return self.async_show_form( step_id="configure_device",