Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnOff trait for climate entities in google_assistant #109160

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions homeassistant/components/google_assistant/trait.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ def supported(domain, features, device_class, _):
if domain == water_heater.DOMAIN and features & WaterHeaterEntityFeature.ON_OFF:
return True

if domain == climate.DOMAIN and features & (
ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
):
return True

return domain in (
group.DOMAIN,
input_boolean.DOMAIN,
Expand Down
7 changes: 6 additions & 1 deletion tests/components/google_assistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def should_2fa(self, state):
"id": "climate.hvac",
"name": {"name": "Hvac"},
"traits": [
"action.devices.traits.OnOff",
"action.devices.traits.TemperatureSetting",
"action.devices.traits.FanSpeed",
],
Expand All @@ -326,14 +327,18 @@ def should_2fa(self, state):
{
"id": "climate.heatpump",
"name": {"name": "HeatPump"},
"traits": ["action.devices.traits.TemperatureSetting"],
"traits": [
"action.devices.traits.OnOff",
"action.devices.traits.TemperatureSetting",
],
"type": "action.devices.types.THERMOSTAT",
"willReportState": False,
},
{
"id": "climate.ecobee",
"name": {"name": "Ecobee"},
"traits": [
"action.devices.traits.OnOff",
"action.devices.traits.TemperatureSetting",
"action.devices.traits.FanSpeed",
],
Expand Down
6 changes: 6 additions & 0 deletions tests/components/google_assistant/test_google_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@ async def test_query_climate_request(
assert len(devices) == 3
assert devices["climate.heatpump"] == {
"online": True,
"on": True,
"thermostatTemperatureSetpoint": 20.0,
"thermostatTemperatureAmbient": 25.0,
"thermostatMode": "heat",
}
assert devices["climate.ecobee"] == {
"online": True,
"on": True,
"thermostatTemperatureSetpointHigh": 24,
"thermostatTemperatureAmbient": 23,
"thermostatMode": "heatcool",
Expand All @@ -247,6 +249,7 @@ async def test_query_climate_request(
}
assert devices["climate.hvac"] == {
"online": True,
"on": True,
"thermostatTemperatureSetpoint": 21,
"thermostatTemperatureAmbient": 22,
"thermostatMode": "cool",
Expand Down Expand Up @@ -294,12 +297,14 @@ async def test_query_climate_request_f(
assert len(devices) == 3
assert devices["climate.heatpump"] == {
"online": True,
"on": True,
"thermostatTemperatureSetpoint": -6.7,
"thermostatTemperatureAmbient": -3.9,
"thermostatMode": "heat",
}
assert devices["climate.ecobee"] == {
"online": True,
"on": True,
"thermostatTemperatureSetpointHigh": -4.4,
"thermostatTemperatureAmbient": -5,
"thermostatMode": "heatcool",
Expand All @@ -308,6 +313,7 @@ async def test_query_climate_request_f(
}
assert devices["climate.hvac"] == {
"online": True,
"on": True,
"thermostatTemperatureSetpoint": -6.1,
"thermostatTemperatureAmbient": -5.6,
"thermostatMode": "cool",
Expand Down
12 changes: 9 additions & 3 deletions tests/components/google_assistant/test_trait.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,9 @@ async def test_temperature_setting_climate_onoff(hass: HomeAssistant) -> None:
"climate.bla",
climate.HVACMode.AUTO,
{
ATTR_SUPPORTED_FEATURES: ClimateEntityFeature.TARGET_TEMPERATURE_RANGE,
ATTR_SUPPORTED_FEATURES: ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
| ClimateEntityFeature.TURN_ON
| ClimateEntityFeature.TURN_OFF,
climate.ATTR_HVAC_MODES: [
climate.HVACMode.OFF,
climate.HVACMode.COOL,
Expand Down Expand Up @@ -1161,7 +1163,9 @@ async def test_temperature_setting_climate_range(hass: HomeAssistant) -> None:
{
climate.ATTR_CURRENT_TEMPERATURE: 70,
climate.ATTR_CURRENT_HUMIDITY: 25,
ATTR_SUPPORTED_FEATURES: ClimateEntityFeature.TARGET_TEMPERATURE_RANGE,
ATTR_SUPPORTED_FEATURES: ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
| ClimateEntityFeature.TURN_ON
| ClimateEntityFeature.TURN_OFF,
climate.ATTR_HVAC_MODES: [
STATE_OFF,
climate.HVACMode.COOL,
Expand Down Expand Up @@ -1273,7 +1277,9 @@ async def test_temperature_setting_climate_setpoint(hass: HomeAssistant) -> None
"climate.bla",
climate.HVACMode.COOL,
{
ATTR_SUPPORTED_FEATURES: ClimateEntityFeature.TARGET_TEMPERATURE,
ATTR_SUPPORTED_FEATURES: ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.TURN_ON
| ClimateEntityFeature.TURN_OFF,
climate.ATTR_HVAC_MODES: [STATE_OFF, climate.HVACMode.COOL],
climate.ATTR_MIN_TEMP: 10,
climate.ATTR_MAX_TEMP: 30,
Expand Down
Loading