From fa9fe4067a08b911bc3c581419ae498c6e12b535 Mon Sep 17 00:00:00 2001 From: Eric Nagley Date: Mon, 10 Dec 2018 06:31:52 -0500 Subject: [PATCH] Google assistant fix target temp for *F values. (#19083) * home-assistant/home-assistant#18524 : Add rounding to *F temps * home-assistant/home-assistant#18524 : Linting * simplify round behavior * fix trailing whitespace (thanks github editor) --- homeassistant/components/google_assistant/trait.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index f2cb819fcc9..e0776d4c636 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -588,8 +588,11 @@ class TemperatureSettingTrait(_Trait): max_temp = self.state.attributes[climate.ATTR_MAX_TEMP] if command == COMMAND_THERMOSTAT_TEMPERATURE_SETPOINT: - temp = temp_util.convert(params['thermostatTemperatureSetpoint'], - TEMP_CELSIUS, unit) + temp = temp_util.convert( + params['thermostatTemperatureSetpoint'], TEMP_CELSIUS, + unit) + if unit == TEMP_FAHRENHEIT: + temp = round(temp) if temp < min_temp or temp > max_temp: raise SmartHomeError( @@ -607,6 +610,8 @@ class TemperatureSettingTrait(_Trait): temp_high = temp_util.convert( params['thermostatTemperatureSetpointHigh'], TEMP_CELSIUS, unit) + if unit == TEMP_FAHRENHEIT: + temp_high = round(temp_high) if temp_high < min_temp or temp_high > max_temp: raise SmartHomeError( @@ -615,7 +620,10 @@ class TemperatureSettingTrait(_Trait): "{} and {}".format(min_temp, max_temp)) temp_low = temp_util.convert( - params['thermostatTemperatureSetpointLow'], TEMP_CELSIUS, unit) + params['thermostatTemperatureSetpointLow'], TEMP_CELSIUS, + unit) + if unit == TEMP_FAHRENHEIT: + temp_low = round(temp_low) if temp_low < min_temp or temp_low > max_temp: raise SmartHomeError(