diff --git a/homeassistant/components/google_assistant/const.py b/homeassistant/components/google_assistant/const.py index 37154bf5e4d..efeb62deb8e 100644 --- a/homeassistant/components/google_assistant/const.py +++ b/homeassistant/components/google_assistant/const.py @@ -10,6 +10,7 @@ from homeassistant.components import ( group, humidifier, input_boolean, + input_button, input_select, light, lock, @@ -129,6 +130,7 @@ DOMAIN_TO_GOOGLE_TYPES = { group.DOMAIN: TYPE_SWITCH, humidifier.DOMAIN: TYPE_HUMIDIFIER, input_boolean.DOMAIN: TYPE_SWITCH, + input_button.DOMAIN: TYPE_SCENE, input_select.DOMAIN: TYPE_SENSOR, light.DOMAIN: TYPE_LIGHT, lock.DOMAIN: TYPE_LOCK, diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index 4b6593abadb..26cce0bd5a5 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -12,6 +12,7 @@ from homeassistant.components import ( fan, group, input_boolean, + input_button, input_select, light, lock, @@ -514,7 +515,12 @@ class SceneTrait(_Trait): @staticmethod def supported(domain, features, device_class, _): """Test if state is supported.""" - return domain in (button.DOMAIN, scene.DOMAIN, script.DOMAIN) + return domain in ( + button.DOMAIN, + input_button.DOMAIN, + scene.DOMAIN, + script.DOMAIN, + ) def sync_attributes(self): """Return scene attributes for a sync request.""" @@ -530,6 +536,8 @@ class SceneTrait(_Trait): service = SERVICE_TURN_ON if self.state.domain == button.DOMAIN: service = button.SERVICE_PRESS + elif self.state.domain == input_button.DOMAIN: + service = input_button.SERVICE_PRESS # Don't block for scripts or buttons, as they can be slow. await self.hass.services.async_call( @@ -537,7 +545,8 @@ class SceneTrait(_Trait): service, {ATTR_ENTITY_ID: self.state.entity_id}, blocking=(not self.config.should_report_state) - and self.state.domain not in (button.DOMAIN, script.DOMAIN), + and self.state.domain + not in (button.DOMAIN, input_button.DOMAIN, script.DOMAIN), context=data.context, ) diff --git a/tests/components/google_assistant/test_trait.py b/tests/components/google_assistant/test_trait.py index e20f08f8702..83fcaa59b19 100644 --- a/tests/components/google_assistant/test_trait.py +++ b/tests/components/google_assistant/test_trait.py @@ -13,6 +13,7 @@ from homeassistant.components import ( fan, group, input_boolean, + input_button, input_select, light, lock, @@ -768,24 +769,30 @@ async def test_light_modes(hass): } -async def test_scene_button(hass): - """Test Scene trait support for the button domain.""" - assert helpers.get_google_type(button.DOMAIN, None) is not None - assert trait.SceneTrait.supported(button.DOMAIN, 0, None, None) +@pytest.mark.parametrize( + "component", + [button, input_button], +) +async def test_scene_button(hass, component): + """Test Scene trait support for the (input) button domain.""" + assert helpers.get_google_type(component.DOMAIN, None) is not None + assert trait.SceneTrait.supported(component.DOMAIN, 0, None, None) - trt = trait.SceneTrait(hass, State("button.bla", STATE_UNKNOWN), BASIC_CONFIG) + trt = trait.SceneTrait( + hass, State(f"{component.DOMAIN}.bla", STATE_UNKNOWN), BASIC_CONFIG + ) assert trt.sync_attributes() == {} assert trt.query_attributes() == {} assert trt.can_execute(trait.COMMAND_ACTIVATE_SCENE, {}) - calls = async_mock_service(hass, button.DOMAIN, button.SERVICE_PRESS) + calls = async_mock_service(hass, component.DOMAIN, component.SERVICE_PRESS) await trt.execute(trait.COMMAND_ACTIVATE_SCENE, BASIC_DATA, {}, {}) # We don't wait till button press is done. await hass.async_block_till_done() assert len(calls) == 1 - assert calls[0].data == {ATTR_ENTITY_ID: "button.bla"} + assert calls[0].data == {ATTR_ENTITY_ID: f"{component.DOMAIN}.bla"} async def test_scene_scene(hass):