From f785cc7d9a4c5cf885b6c5cda0141d3b3c1f4cd8 Mon Sep 17 00:00:00 2001 From: Tobias Haber Date: Thu, 18 Mar 2021 04:59:06 +0100 Subject: [PATCH] Google has deprecated a comma separated list for modes changed it to array (#48029) --- homeassistant/components/google_assistant/trait.py | 2 +- tests/components/google_assistant/__init__.py | 10 +++++++++- tests/components/google_assistant/test_trait.py | 10 +++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index be7ceb98ad3..7babc5e4836 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -763,7 +763,7 @@ class TemperatureSettingTrait(_Trait): mode in modes for mode in ("heatcool", "heat", "cool") ): modes.append("on") - response["availableThermostatModes"] = ",".join(modes) + response["availableThermostatModes"] = modes return response diff --git a/tests/components/google_assistant/__init__.py b/tests/components/google_assistant/__init__.py index 4bef45cf0ee..9047e175ae6 100644 --- a/tests/components/google_assistant/__init__.py +++ b/tests/components/google_assistant/__init__.py @@ -276,7 +276,15 @@ DEMO_DEVICES = [ "type": "action.devices.types.THERMOSTAT", "willReportState": False, "attributes": { - "availableThermostatModes": "off,heat,cool,heatcool,auto,dry,fan-only", + "availableThermostatModes": [ + "off", + "heat", + "cool", + "heatcool", + "auto", + "dry", + "fan-only", + ], "thermostatTemperatureUnit": "C", }, }, diff --git a/tests/components/google_assistant/test_trait.py b/tests/components/google_assistant/test_trait.py index 43e9c30f91a..fd62d225aac 100644 --- a/tests/components/google_assistant/test_trait.py +++ b/tests/components/google_assistant/test_trait.py @@ -713,7 +713,7 @@ async def test_temperature_setting_climate_onoff(hass): BASIC_CONFIG, ) assert trt.sync_attributes() == { - "availableThermostatModes": "off,cool,heat,heatcool,on", + "availableThermostatModes": ["off", "cool", "heat", "heatcool", "on"], "thermostatTemperatureUnit": "F", } assert trt.can_execute(trait.COMMAND_THERMOSTAT_SET_MODE, {}) @@ -752,7 +752,7 @@ async def test_temperature_setting_climate_no_modes(hass): BASIC_CONFIG, ) assert trt.sync_attributes() == { - "availableThermostatModes": "heat", + "availableThermostatModes": ["heat"], "thermostatTemperatureUnit": "C", } @@ -788,7 +788,7 @@ async def test_temperature_setting_climate_range(hass): BASIC_CONFIG, ) assert trt.sync_attributes() == { - "availableThermostatModes": "off,cool,heat,auto,on", + "availableThermostatModes": ["off", "cool", "heat", "auto", "on"], "thermostatTemperatureUnit": "F", } assert trt.query_attributes() == { @@ -862,7 +862,7 @@ async def test_temperature_setting_climate_setpoint(hass): BASIC_CONFIG, ) assert trt.sync_attributes() == { - "availableThermostatModes": "off,cool,on", + "availableThermostatModes": ["off", "cool", "on"], "thermostatTemperatureUnit": "C", } assert trt.query_attributes() == { @@ -920,7 +920,7 @@ async def test_temperature_setting_climate_setpoint_auto(hass): BASIC_CONFIG, ) assert trt.sync_attributes() == { - "availableThermostatModes": "off,heatcool,on", + "availableThermostatModes": ["off", "heatcool", "on"], "thermostatTemperatureUnit": "C", } assert trt.query_attributes() == {