ESPHome: Add additional field for current temperature precision (#88464)

This commit is contained in:
Jesse Hills 2023-02-20 21:54:40 +13:00 committed by GitHub
parent ba2e80f741
commit 6da524b378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View File

@ -142,8 +142,12 @@ class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEnti
def precision(self) -> float: def precision(self) -> float:
"""Return the precision of the climate device.""" """Return the precision of the climate device."""
precicions = [PRECISION_WHOLE, PRECISION_HALVES, PRECISION_TENTHS] precicions = [PRECISION_WHOLE, PRECISION_HALVES, PRECISION_TENTHS]
if self._static_info.visual_current_temperature_step != 0:
step = self._static_info.visual_current_temperature_step
else:
step = self._static_info.visual_target_temperature_step
for prec in precicions: for prec in precicions:
if self._static_info.visual_temperature_step >= prec: if step >= prec:
return prec return prec
# Fall back to highest precision, tenths # Fall back to highest precision, tenths
return PRECISION_TENTHS return PRECISION_TENTHS
@ -184,7 +188,7 @@ class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEnti
def target_temperature_step(self) -> float: def target_temperature_step(self) -> float:
"""Return the supported step of target temperature.""" """Return the supported step of target temperature."""
# Round to one digit because of floating point math # Round to one digit because of floating point math
return round(self._static_info.visual_temperature_step, 1) return round(self._static_info.visual_target_temperature_step, 1)
@property @property
def min_temp(self) -> float: def min_temp(self) -> float:

View File

@ -14,6 +14,6 @@
"integration_type": "device", "integration_type": "device",
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["aioesphomeapi", "noiseprotocol"], "loggers": ["aioesphomeapi", "noiseprotocol"],
"requirements": ["aioesphomeapi==13.3.1", "esphome-dashboard-api==1.2.3"], "requirements": ["aioesphomeapi==13.4.0", "esphome-dashboard-api==1.2.3"],
"zeroconf": ["_esphomelib._tcp.local."] "zeroconf": ["_esphomelib._tcp.local."]
} }

View File

@ -156,7 +156,7 @@ aioecowitt==2023.01.0
aioemonitor==1.0.5 aioemonitor==1.0.5
# homeassistant.components.esphome # homeassistant.components.esphome
aioesphomeapi==13.3.1 aioesphomeapi==13.4.0
# homeassistant.components.flo # homeassistant.components.flo
aioflo==2021.11.0 aioflo==2021.11.0

View File

@ -143,7 +143,7 @@ aioecowitt==2023.01.0
aioemonitor==1.0.5 aioemonitor==1.0.5
# homeassistant.components.esphome # homeassistant.components.esphome
aioesphomeapi==13.3.1 aioesphomeapi==13.4.0
# homeassistant.components.flo # homeassistant.components.flo
aioflo==2021.11.0 aioflo==2021.11.0