mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add scenes as switches HomeKit (#17799)
This commit is contained in:
parent
93b16e7efb
commit
c59b038512
@ -170,7 +170,8 @@ def get_accessory(hass, driver, state, aid, config):
|
||||
switch_type = config.get(CONF_TYPE, TYPE_SWITCH)
|
||||
a_type = SWITCH_TYPES[switch_type]
|
||||
|
||||
elif state.domain in ('automation', 'input_boolean', 'remote', 'script'):
|
||||
elif state.domain in ('automation', 'input_boolean', 'remote', 'scene',
|
||||
'script'):
|
||||
a_type = 'Switch'
|
||||
|
||||
elif state.domain == 'water_heater':
|
||||
|
@ -86,6 +86,8 @@ class Switch(HomeAccessory):
|
||||
def is_activate(self, state):
|
||||
"""Check if entity is activate only."""
|
||||
can_cancel = state.attributes.get(ATTR_CAN_CANCEL)
|
||||
if self._domain == 'scene':
|
||||
return True
|
||||
if self._domain == 'script' and not can_cancel:
|
||||
return True
|
||||
return False
|
||||
|
@ -139,6 +139,7 @@ def test_type_sensors(type_name, entity_id, state, attrs):
|
||||
('Switch', 'automation.test', 'on', {}, {}),
|
||||
('Switch', 'input_boolean.test', 'on', {}, {}),
|
||||
('Switch', 'remote.test', 'on', {}, {}),
|
||||
('Switch', 'scene.test', 'on', {}, {}),
|
||||
('Switch', 'script.test', 'on', {}, {}),
|
||||
('Switch', 'switch.test', 'on', {}, {}),
|
||||
('Switch', 'switch.test', 'on', {}, {CONF_TYPE: TYPE_SWITCH}),
|
||||
|
@ -180,6 +180,7 @@ async def test_valve_set_state(hass, hk_driver, events):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('entity_id, attrs', [
|
||||
('scene.test', {}),
|
||||
('script.test', {}),
|
||||
('script.test', {ATTR_CAN_CANCEL: False}),
|
||||
])
|
||||
|
Loading…
x
Reference in New Issue
Block a user