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
This commit is contained in:
Lincoln Kirchoff 2021-07-13 03:36:54 -05:00 committed by GitHub
parent c5556a091e
commit ac39607ae9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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."""