mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add input_button support to Alexa (#62592)
This commit is contained in:
parent
23277181ca
commit
99b2161365
@ -16,6 +16,7 @@ from homeassistant.components import (
|
|||||||
group,
|
group,
|
||||||
image_processing,
|
image_processing,
|
||||||
input_boolean,
|
input_boolean,
|
||||||
|
input_button,
|
||||||
input_number,
|
input_number,
|
||||||
light,
|
light,
|
||||||
lock,
|
lock,
|
||||||
@ -426,6 +427,7 @@ class SwitchCapabilities(AlexaEntity):
|
|||||||
|
|
||||||
|
|
||||||
@ENTITY_ADAPTERS.register(button.DOMAIN)
|
@ENTITY_ADAPTERS.register(button.DOMAIN)
|
||||||
|
@ENTITY_ADAPTERS.register(input_button.DOMAIN)
|
||||||
class ButtonCapabilities(AlexaEntity):
|
class ButtonCapabilities(AlexaEntity):
|
||||||
"""Class to represent Button capabilities."""
|
"""Class to represent Button capabilities."""
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ from homeassistant.components import (
|
|||||||
cover,
|
cover,
|
||||||
fan,
|
fan,
|
||||||
group,
|
group,
|
||||||
|
input_button,
|
||||||
input_number,
|
input_number,
|
||||||
light,
|
light,
|
||||||
media_player,
|
media_player,
|
||||||
@ -317,6 +318,8 @@ async def async_api_activate(hass, config, directive, context):
|
|||||||
service = SERVICE_TURN_ON
|
service = SERVICE_TURN_ON
|
||||||
if domain == button.DOMAIN:
|
if domain == button.DOMAIN:
|
||||||
service = button.SERVICE_PRESS
|
service = button.SERVICE_PRESS
|
||||||
|
elif domain == input_button.DOMAIN:
|
||||||
|
service = input_button.SERVICE_PRESS
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
domain,
|
domain,
|
||||||
|
@ -3939,12 +3939,20 @@ async def test_initialize_camera_stream(hass, mock_camera, mock_stream):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_button(hass):
|
@pytest.mark.parametrize(
|
||||||
|
"domain",
|
||||||
|
["button", "input_button"],
|
||||||
|
)
|
||||||
|
async def test_button(hass, domain):
|
||||||
"""Test button discovery."""
|
"""Test button discovery."""
|
||||||
device = ("button.ring_doorbell", STATE_UNKNOWN, {"friendly_name": "Ring Doorbell"})
|
device = (
|
||||||
|
f"{domain}.ring_doorbell",
|
||||||
|
STATE_UNKNOWN,
|
||||||
|
{"friendly_name": "Ring Doorbell"},
|
||||||
|
)
|
||||||
appliance = await discovery_test(device, hass)
|
appliance = await discovery_test(device, hass)
|
||||||
|
|
||||||
assert appliance["endpointId"] == "button#ring_doorbell"
|
assert appliance["endpointId"] == f"{domain}#ring_doorbell"
|
||||||
assert appliance["displayCategories"][0] == "ACTIVITY_TRIGGER"
|
assert appliance["displayCategories"][0] == "ACTIVITY_TRIGGER"
|
||||||
assert appliance["friendlyName"] == "Ring Doorbell"
|
assert appliance["friendlyName"] == "Ring Doorbell"
|
||||||
|
|
||||||
@ -3955,5 +3963,5 @@ async def test_button(hass):
|
|||||||
assert scene_capability["supportsDeactivation"] is False
|
assert scene_capability["supportsDeactivation"] is False
|
||||||
|
|
||||||
await assert_scene_controller_works(
|
await assert_scene_controller_works(
|
||||||
"button#ring_doorbell", "button.press", False, hass
|
f"{domain}#ring_doorbell", f"{domain}.press", False, hass
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user