Add input_button support to HomeKit (#62590)
This commit is contained in:
parent
cb82169e92
commit
c5d62ccc7e
5 changed files with 14 additions and 6 deletions
|
@ -198,6 +198,7 @@ def get_accessory(hass, driver, state, aid, config): # noqa: C901
|
|||
"automation",
|
||||
"button",
|
||||
"input_boolean",
|
||||
"input_button",
|
||||
"remote",
|
||||
"scene",
|
||||
"script",
|
||||
|
|
|
@ -85,6 +85,7 @@ SUPPORTED_DOMAINS = [
|
|||
"fan",
|
||||
"humidifier",
|
||||
"input_boolean",
|
||||
"input_button",
|
||||
"input_select",
|
||||
"light",
|
||||
"lock",
|
||||
|
|
|
@ -12,7 +12,7 @@ from pyhap.const import (
|
|||
CATEGORY_SWITCH,
|
||||
)
|
||||
|
||||
from homeassistant.components import button
|
||||
from homeassistant.components import button, input_button
|
||||
from homeassistant.components.input_select import ATTR_OPTIONS, SERVICE_SELECT_OPTION
|
||||
from homeassistant.components.switch import DOMAIN
|
||||
from homeassistant.components.vacuum import (
|
||||
|
@ -70,7 +70,7 @@ VALVE_TYPE: dict[str, ValveInfo] = {
|
|||
}
|
||||
|
||||
|
||||
ACTIVATE_ONLY_SWITCH_DOMAINS = {"button", "scene", "script"}
|
||||
ACTIVATE_ONLY_SWITCH_DOMAINS = {"button", "input_button", "scene", "script"}
|
||||
|
||||
ACTIVATE_ONLY_RESET_SECONDS = 10
|
||||
|
||||
|
@ -152,6 +152,8 @@ class Switch(HomeAccessory):
|
|||
params = {}
|
||||
elif self._domain == button.DOMAIN:
|
||||
service = button.SERVICE_PRESS
|
||||
elif self._domain == input_button.DOMAIN:
|
||||
service = input_button.SERVICE_PRESS
|
||||
else:
|
||||
service = SERVICE_TURN_ON if value else SERVICE_TURN_OFF
|
||||
|
||||
|
|
|
@ -272,6 +272,7 @@ def test_type_sensors(type_name, entity_id, state, attrs):
|
|||
("Switch", "automation.test", "on", {}, {}),
|
||||
("Switch", "button.test", STATE_UNKNOWN, {}, {}),
|
||||
("Switch", "input_boolean.test", "on", {}, {}),
|
||||
("Switch", "input_button.test", STATE_UNKNOWN, {}, {}),
|
||||
("Switch", "remote.test", "on", {}, {}),
|
||||
("Switch", "scene.test", "on", {}, {}),
|
||||
("Switch", "script.test", "on", {}, {}),
|
||||
|
|
|
@ -451,10 +451,13 @@ async def test_input_select_switch(hass, hk_driver, events, domain):
|
|||
assert acc.select_chars["option3"].value is False
|
||||
|
||||
|
||||
async def test_button_switch(hass, hk_driver, events):
|
||||
"""Test switch accessory from a button entity."""
|
||||
domain = "button"
|
||||
entity_id = "button.test"
|
||||
@pytest.mark.parametrize(
|
||||
"domain",
|
||||
["button", "input_button"],
|
||||
)
|
||||
async def test_button_switch(hass, hk_driver, events, domain):
|
||||
"""Test switch accessory from a (input) button entity."""
|
||||
entity_id = f"{domain}.test"
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Add table
Reference in a new issue