From c7fbbbe9359d2ce621c440bda4b353db1ae920b3 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Sat, 31 Oct 2020 16:19:17 +0100 Subject: [PATCH] Allow saving zero precision option in Opentherm_gw (#42593) * Allow saving zero precision option in Opentherm_gw * Add default 0 back for precision option * Adjust config flow test for zero precision --- homeassistant/components/opentherm_gw/climate.py | 5 ++--- homeassistant/components/opentherm_gw/config_flow.py | 2 -- tests/components/opentherm_gw/test_config_flow.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/opentherm_gw/climate.py b/homeassistant/components/opentherm_gw/climate.py index 64625541352..237733e6870 100644 --- a/homeassistant/components/opentherm_gw/climate.py +++ b/homeassistant/components/opentherm_gw/climate.py @@ -33,7 +33,6 @@ from .const import CONF_FLOOR_TEMP, CONF_PRECISION, DATA_GATEWAYS, DATA_OPENTHER _LOGGER = logging.getLogger(__name__) DEFAULT_FLOOR_TEMP = False -DEFAULT_PRECISION = None SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE @@ -62,7 +61,7 @@ class OpenThermClimate(ClimateEntity): ) self.friendly_name = gw_dev.name self.floor_temp = options.get(CONF_FLOOR_TEMP, DEFAULT_FLOOR_TEMP) - self.temp_precision = options.get(CONF_PRECISION, DEFAULT_PRECISION) + self.temp_precision = options.get(CONF_PRECISION) self._available = False self._current_operation = None self._current_temperature = None @@ -177,7 +176,7 @@ class OpenThermClimate(ClimateEntity): @property def precision(self): """Return the precision of the system.""" - if self.temp_precision is not None: + if self.temp_precision is not None and self.temp_precision != 0: return self.temp_precision if self.hass.config.units.temperature_unit == TEMP_CELSIUS: return PRECISION_HALVES diff --git a/homeassistant/components/opentherm_gw/config_flow.py b/homeassistant/components/opentherm_gw/config_flow.py index 60d367db5a1..59f14ab2ee5 100644 --- a/homeassistant/components/opentherm_gw/config_flow.py +++ b/homeassistant/components/opentherm_gw/config_flow.py @@ -114,8 +114,6 @@ class OpenThermGwOptionsFlow(config_entries.OptionsFlow): async def async_step_init(self, user_input=None): """Manage the opentherm_gw options.""" if user_input is not None: - if user_input.get(CONF_PRECISION) == 0: - user_input[CONF_PRECISION] = None return self.async_create_entry(title="", data=user_input) return self.async_show_form( diff --git a/tests/components/opentherm_gw/test_config_flow.py b/tests/components/opentherm_gw/test_config_flow.py index 2f4c171cf36..a7be6ddcf6b 100644 --- a/tests/components/opentherm_gw/test_config_flow.py +++ b/tests/components/opentherm_gw/test_config_flow.py @@ -206,5 +206,5 @@ async def test_options_form(hass): ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY - assert result["data"][CONF_PRECISION] is None + assert result["data"][CONF_PRECISION] == 0.0 assert result["data"][CONF_FLOOR_TEMP] is True