Clean up rounding in Ecobee integration (#56319)
This commit is contained in:
parent
b0e1bab58b
commit
6b9fb4bda3
2 changed files with 17 additions and 11 deletions
|
@ -32,6 +32,7 @@ from homeassistant.components.climate.const import (
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
ATTR_TEMPERATURE,
|
ATTR_TEMPERATURE,
|
||||||
|
PRECISION_HALVES,
|
||||||
PRECISION_TENTHS,
|
PRECISION_TENTHS,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
|
@ -394,24 +395,29 @@ class Thermostat(ClimateEntity):
|
||||||
return PRECISION_TENTHS
|
return PRECISION_TENTHS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self) -> float:
|
||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
return self.thermostat["runtime"]["actualTemperature"] / 10.0
|
return self.thermostat["runtime"]["actualTemperature"] / 10.0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_low(self):
|
def target_temperature_low(self) -> float | None:
|
||||||
"""Return the lower bound temperature we try to reach."""
|
"""Return the lower bound temperature we try to reach."""
|
||||||
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
|
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
|
||||||
return round(self.thermostat["runtime"]["desiredHeat"] / 10.0)
|
return self.thermostat["runtime"]["desiredHeat"] / 10.0
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_high(self):
|
def target_temperature_high(self) -> float | None:
|
||||||
"""Return the upper bound temperature we try to reach."""
|
"""Return the upper bound temperature we try to reach."""
|
||||||
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
|
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
|
||||||
return round(self.thermostat["runtime"]["desiredCool"] / 10.0)
|
return self.thermostat["runtime"]["desiredCool"] / 10.0
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature_step(self) -> float:
|
||||||
|
"""Set target temperature step to halves."""
|
||||||
|
return PRECISION_HALVES
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_humidifier_control(self):
|
def has_humidifier_control(self):
|
||||||
"""Return true if humidifier connected to thermostat and set to manual/on mode."""
|
"""Return true if humidifier connected to thermostat and set to manual/on mode."""
|
||||||
|
@ -438,14 +444,14 @@ class Thermostat(ClimateEntity):
|
||||||
return DEFAULT_MAX_HUMIDITY
|
return DEFAULT_MAX_HUMIDITY
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self):
|
def target_temperature(self) -> float | None:
|
||||||
"""Return the temperature we try to reach."""
|
"""Return the temperature we try to reach."""
|
||||||
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
|
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
|
||||||
return None
|
return None
|
||||||
if self.hvac_mode == HVAC_MODE_HEAT:
|
if self.hvac_mode == HVAC_MODE_HEAT:
|
||||||
return round(self.thermostat["runtime"]["desiredHeat"] / 10.0)
|
return self.thermostat["runtime"]["desiredHeat"] / 10.0
|
||||||
if self.hvac_mode == HVAC_MODE_COOL:
|
if self.hvac_mode == HVAC_MODE_COOL:
|
||||||
return round(self.thermostat["runtime"]["desiredCool"] / 10.0)
|
return self.thermostat["runtime"]["desiredCool"] / 10.0
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -682,7 +688,7 @@ class Thermostat(ClimateEntity):
|
||||||
heat_temp = temp
|
heat_temp = temp
|
||||||
cool_temp = temp
|
cool_temp = temp
|
||||||
else:
|
else:
|
||||||
delta = self.thermostat["settings"]["heatCoolMinDelta"] / 10
|
delta = self.thermostat["settings"]["heatCoolMinDelta"] / 10.0
|
||||||
heat_temp = temp - delta
|
heat_temp = temp - delta
|
||||||
cool_temp = temp + delta
|
cool_temp = temp + delta
|
||||||
self.set_auto_temp_hold(heat_temp, cool_temp)
|
self.set_auto_temp_hold(heat_temp, cool_temp)
|
||||||
|
|
|
@ -87,14 +87,14 @@ async def test_target_temperature_low(ecobee_fixture, thermostat):
|
||||||
"""Test target low temperature."""
|
"""Test target low temperature."""
|
||||||
assert thermostat.target_temperature_low == 40
|
assert thermostat.target_temperature_low == 40
|
||||||
ecobee_fixture["runtime"]["desiredHeat"] = 502
|
ecobee_fixture["runtime"]["desiredHeat"] = 502
|
||||||
assert thermostat.target_temperature_low == 50
|
assert thermostat.target_temperature_low == 50.2
|
||||||
|
|
||||||
|
|
||||||
async def test_target_temperature_high(ecobee_fixture, thermostat):
|
async def test_target_temperature_high(ecobee_fixture, thermostat):
|
||||||
"""Test target high temperature."""
|
"""Test target high temperature."""
|
||||||
assert thermostat.target_temperature_high == 20
|
assert thermostat.target_temperature_high == 20
|
||||||
ecobee_fixture["runtime"]["desiredCool"] = 679
|
ecobee_fixture["runtime"]["desiredCool"] = 679
|
||||||
assert thermostat.target_temperature_high == 68
|
assert thermostat.target_temperature_high == 67.9
|
||||||
|
|
||||||
|
|
||||||
async def test_target_temperature(ecobee_fixture, thermostat):
|
async def test_target_temperature(ecobee_fixture, thermostat):
|
||||||
|
|
Loading…
Add table
Reference in a new issue