mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix Google Assistant temperature control for entity without mo… (#33107)
This commit is contained in:
parent
45241e57ca
commit
6180f7bd64
@ -647,6 +647,14 @@ class TemperatureSettingTrait(_Trait):
|
||||
|
||||
elif domain == climate.DOMAIN:
|
||||
modes = self.climate_google_modes
|
||||
|
||||
# Some integrations don't support modes (e.g. opentherm), but Google doesn't
|
||||
# support changing the temperature if we don't have any modes. If there's
|
||||
# only one Google doesn't support changing it, so the default mode here is
|
||||
# only cosmetic.
|
||||
if len(modes) == 0:
|
||||
modes.append("heat")
|
||||
|
||||
if "off" in modes and any(
|
||||
mode in modes for mode in ("heatcool", "heat", "cool")
|
||||
):
|
||||
|
@ -557,6 +557,32 @@ async def test_temperature_setting_climate_onoff(hass):
|
||||
assert len(calls) == 1
|
||||
|
||||
|
||||
async def test_temperature_setting_climate_no_modes(hass):
|
||||
"""Test TemperatureSetting trait support for climate domain not supporting any modes."""
|
||||
assert helpers.get_google_type(climate.DOMAIN, None) is not None
|
||||
assert trait.TemperatureSettingTrait.supported(climate.DOMAIN, 0, None)
|
||||
|
||||
hass.config.units.temperature_unit = TEMP_CELSIUS
|
||||
|
||||
trt = trait.TemperatureSettingTrait(
|
||||
hass,
|
||||
State(
|
||||
"climate.bla",
|
||||
climate.HVAC_MODE_AUTO,
|
||||
{
|
||||
climate.ATTR_HVAC_MODES: [],
|
||||
climate.ATTR_MIN_TEMP: None,
|
||||
climate.ATTR_MAX_TEMP: None,
|
||||
},
|
||||
),
|
||||
BASIC_CONFIG,
|
||||
)
|
||||
assert trt.sync_attributes() == {
|
||||
"availableThermostatModes": "heat",
|
||||
"thermostatTemperatureUnit": "C",
|
||||
}
|
||||
|
||||
|
||||
async def test_temperature_setting_climate_range(hass):
|
||||
"""Test TemperatureSetting trait support for climate domain - range."""
|
||||
assert helpers.get_google_type(climate.DOMAIN, None) is not None
|
||||
|
Loading…
x
Reference in New Issue
Block a user