From e1a5e5a8ba5f922d5d223b0b2f97d5d9e60aba6f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen <paulus@paulusschoutsen.nl> Date: Wed, 14 Mar 2018 15:07:37 -0700 Subject: [PATCH] Fix input_boolean Google Assistant serialize error (#13220) --- .../components/google_assistant/smart_home.py | 22 ++++++++++++++----- .../google_assistant/test_smart_home.py | 15 +++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/google_assistant/smart_home.py b/homeassistant/components/google_assistant/smart_home.py index 48d24c00b97..834d40c367c 100644 --- a/homeassistant/components/google_assistant/smart_home.py +++ b/homeassistant/components/google_assistant/smart_home.py @@ -17,7 +17,16 @@ from homeassistant.core import callback from homeassistant.const import ( CONF_NAME, STATE_UNAVAILABLE, ATTR_SUPPORTED_FEATURES) from homeassistant.components import ( - switch, light, cover, media_player, group, fan, scene, script, climate, + climate, + cover, + fan, + group, + input_boolean, + light, + media_player, + scene, + script, + switch, ) from . import trait @@ -33,15 +42,16 @@ HANDLERS = Registry() _LOGGER = logging.getLogger(__name__) DOMAIN_TO_GOOGLE_TYPES = { + climate.DOMAIN: TYPE_THERMOSTAT, + cover.DOMAIN: TYPE_SWITCH, + fan.DOMAIN: TYPE_SWITCH, group.DOMAIN: TYPE_SWITCH, + input_boolean.DOMAIN: TYPE_SWITCH, + light.DOMAIN: TYPE_LIGHT, + media_player.DOMAIN: TYPE_SWITCH, scene.DOMAIN: TYPE_SCENE, script.DOMAIN: TYPE_SCENE, switch.DOMAIN: TYPE_SWITCH, - fan.DOMAIN: TYPE_SWITCH, - light.DOMAIN: TYPE_LIGHT, - cover.DOMAIN: TYPE_SWITCH, - media_player.DOMAIN: TYPE_SWITCH, - climate.DOMAIN: TYPE_THERMOSTAT, } diff --git a/tests/components/google_assistant/test_smart_home.py b/tests/components/google_assistant/test_smart_home.py index 8d139fa8211..24d74afa6da 100644 --- a/tests/components/google_assistant/test_smart_home.py +++ b/tests/components/google_assistant/test_smart_home.py @@ -1,4 +1,5 @@ """Test Google Smart Home.""" +from homeassistant.core import State from homeassistant.const import ( ATTR_SUPPORTED_FEATURES, ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS) from homeassistant.setup import async_setup_component @@ -244,3 +245,17 @@ async def test_raising_error_trait(hass): }] } } + + +def test_serialize_input_boolean(): + """Test serializing an input boolean entity.""" + state = State('input_boolean.bla', 'on') + entity = sh._GoogleEntity(None, BASIC_CONFIG, state) + assert entity.sync_serialize() == { + 'id': 'input_boolean.bla', + 'attributes': {}, + 'name': {'name': 'bla'}, + 'traits': ['action.devices.traits.OnOff'], + 'type': 'action.devices.types.SWITCH', + 'willReportState': False, + } -- GitLab