Use climate enums in google_assistant (#75888)

This commit is contained in:
Nephiel 2022-07-29 12:08:32 +02:00 committed by GitHub
parent 08b169a7ad
commit ab5dfb3c42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -864,13 +864,13 @@ class TemperatureSettingTrait(_Trait):
# We do not support "on" as we are unable to know how to restore
# the last mode.
hvac_to_google = {
climate.HVAC_MODE_HEAT: "heat",
climate.HVAC_MODE_COOL: "cool",
climate.HVAC_MODE_OFF: "off",
climate.HVAC_MODE_AUTO: "auto",
climate.HVAC_MODE_HEAT_COOL: "heatcool",
climate.HVAC_MODE_FAN_ONLY: "fan-only",
climate.HVAC_MODE_DRY: "dry",
climate.HVACMode.HEAT: "heat",
climate.HVACMode.COOL: "cool",
climate.HVACMode.OFF: "off",
climate.HVACMode.AUTO: "auto",
climate.HVACMode.HEAT_COOL: "heatcool",
climate.HVACMode.FAN_ONLY: "fan-only",
climate.HVACMode.DRY: "dry",
}
google_to_hvac = {value: key for key, value in hvac_to_google.items()}
@ -949,7 +949,7 @@ class TemperatureSettingTrait(_Trait):
if current_humidity is not None:
response["thermostatHumidityAmbient"] = current_humidity
if operation in (climate.HVAC_MODE_AUTO, climate.HVAC_MODE_HEAT_COOL):
if operation in (climate.HVACMode.AUTO, climate.HVACMode.HEAT_COOL):
if supported & climate.SUPPORT_TARGET_TEMPERATURE_RANGE:
response["thermostatTemperatureSetpointHigh"] = round(
temp_util.convert(