Set temperature precision for Ecobee climate entities to tenths ()

pull/49448/head
jjlawren 2021-04-19 19:41:30 -05:00 committed by GitHub
parent f6a24e8d68
commit 523a71ac20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions
homeassistant/components/ecobee
tests/components/ecobee

View File

@ -32,6 +32,7 @@ from homeassistant.components.climate.const import (
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_TEMPERATURE,
PRECISION_TENTHS,
STATE_ON,
TEMP_FAHRENHEIT,
)
@ -379,6 +380,11 @@ class Thermostat(ClimateEntity):
"""Return the unit of measurement."""
return TEMP_FAHRENHEIT
@property
def precision(self) -> float:
"""Return the precision of the system."""
return PRECISION_TENTHS
@property
def current_temperature(self):
"""Return the current temperature."""
@ -388,14 +394,14 @@ class Thermostat(ClimateEntity):
def target_temperature_low(self):
"""Return the lower bound temperature we try to reach."""
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
return self.thermostat["runtime"]["desiredHeat"] / 10.0
return round(self.thermostat["runtime"]["desiredHeat"] / 10.0)
return None
@property
def target_temperature_high(self):
"""Return the upper bound temperature we try to reach."""
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
return self.thermostat["runtime"]["desiredCool"] / 10.0
return round(self.thermostat["runtime"]["desiredCool"] / 10.0)
return None
@property
@ -429,9 +435,9 @@ class Thermostat(ClimateEntity):
if self.hvac_mode == HVAC_MODE_HEAT_COOL:
return None
if self.hvac_mode == HVAC_MODE_HEAT:
return self.thermostat["runtime"]["desiredHeat"] / 10.0
return round(self.thermostat["runtime"]["desiredHeat"] / 10.0)
if self.hvac_mode == HVAC_MODE_COOL:
return self.thermostat["runtime"]["desiredCool"] / 10.0
return round(self.thermostat["runtime"]["desiredCool"] / 10.0)
return None
@property

View File

@ -83,14 +83,14 @@ async def test_target_temperature_low(ecobee_fixture, thermostat):
"""Test target low temperature."""
assert thermostat.target_temperature_low == 40
ecobee_fixture["runtime"]["desiredHeat"] = 502
assert thermostat.target_temperature_low == 50.2
assert thermostat.target_temperature_low == 50
async def test_target_temperature_high(ecobee_fixture, thermostat):
"""Test target high temperature."""
assert thermostat.target_temperature_high == 20
ecobee_fixture["runtime"]["desiredCool"] = 103
assert thermostat.target_temperature_high == 10.3
ecobee_fixture["runtime"]["desiredCool"] = 679
assert thermostat.target_temperature_high == 68
async def test_target_temperature(ecobee_fixture, thermostat):