From ac39607ae973dcd9b91fc03967c0aca721320f4b Mon Sep 17 00:00:00 2001 From: Lincoln Kirchoff Date: Tue, 13 Jul 2021 03:36:54 -0500 Subject: [PATCH] Fix modbus climate precision configuration variable (#52651) * Updated precision to follow the tenths, halves, whole notation used by other home assistant climate modules. Added the precision @property so that home assistant can handle this rounding in the frontend, rather than in the _async_read_register() method. * Fixed a pylinter error for periods in user-facing log messages, and updated `precision` defaults in components/modbus/__init__.py to be consistent with an error case, using `PRECISION_WHOLE`. * revert changes to `precision:` configuration variable instead, the climate `precision()` function will infer whether or not to display in whole or tenths. halves will be unsupported, which should be fine. * re-added missing line that was removed * revert change to use self._input_type instead of CALL_TYPE_REGISTER_HOLDING --- homeassistant/components/modbus/climate.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/homeassistant/components/modbus/climate.py b/homeassistant/components/modbus/climate.py index bfc04024e45..54894a4227c 100644 --- a/homeassistant/components/modbus/climate.py +++ b/homeassistant/components/modbus/climate.py @@ -16,6 +16,8 @@ from homeassistant.const import ( CONF_OFFSET, CONF_STRUCTURE, CONF_TEMPERATURE_UNIT, + PRECISION_TENTHS, + PRECISION_WHOLE, TEMP_CELSIUS, TEMP_FAHRENHEIT, ) @@ -134,6 +136,11 @@ class ModbusThermostat(BasePlatform, RestoreEntity, ClimateEntity): """Return the unit of measurement.""" return TEMP_FAHRENHEIT if self._unit == "F" else TEMP_CELSIUS + @property + def precision(self) -> float: + """Return the precision of the system.""" + return PRECISION_TENTHS if self._precision >= 1 else PRECISION_WHOLE + @property def min_temp(self): """Return the minimum temperature."""