1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Add input_button support to Google Assistant (#62593)

This commit is contained in:
Franck Nijhof
2021-12-23 07:38:35 +01:00
committed by GitHub
parent 99b2161365
commit dc47cbd01b
3 changed files with 27 additions and 9 deletions

View File

@@ -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):