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
This commit is contained in:
springstan 2020-10-31 16:19:17 +01:00 committed by GitHub
parent d67d8e76dd
commit c7fbbbe935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 6 deletions

View File

@ -33,7 +33,6 @@ from .const import CONF_FLOOR_TEMP, CONF_PRECISION, DATA_GATEWAYS, DATA_OPENTHER
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEFAULT_FLOOR_TEMP = False DEFAULT_FLOOR_TEMP = False
DEFAULT_PRECISION = None
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
@ -62,7 +61,7 @@ class OpenThermClimate(ClimateEntity):
) )
self.friendly_name = gw_dev.name self.friendly_name = gw_dev.name
self.floor_temp = options.get(CONF_FLOOR_TEMP, DEFAULT_FLOOR_TEMP) 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._available = False
self._current_operation = None self._current_operation = None
self._current_temperature = None self._current_temperature = None
@ -177,7 +176,7 @@ class OpenThermClimate(ClimateEntity):
@property @property
def precision(self): def precision(self):
"""Return the precision of the system.""" """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 return self.temp_precision
if self.hass.config.units.temperature_unit == TEMP_CELSIUS: if self.hass.config.units.temperature_unit == TEMP_CELSIUS:
return PRECISION_HALVES return PRECISION_HALVES

View File

@ -114,8 +114,6 @@ class OpenThermGwOptionsFlow(config_entries.OptionsFlow):
async def async_step_init(self, user_input=None): async def async_step_init(self, user_input=None):
"""Manage the opentherm_gw options.""" """Manage the opentherm_gw options."""
if user_input is not None: 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_create_entry(title="", data=user_input)
return self.async_show_form( return self.async_show_form(

View File

@ -206,5 +206,5 @@ async def test_options_form(hass):
) )
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY 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 assert result["data"][CONF_FLOOR_TEMP] is True