mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
deCONZ - Support Symfonisk sound controller with device triggers (#26913)
* Device trigger tests shall use the common gateway mock * Follow ebaauws clarification of signals * Fix translations
This commit is contained in:
parent
09c5b9feb3
commit
d8c6b281b8
@ -64,6 +64,7 @@
|
|||||||
"remote_button_quadruple_press": "\"{subtype}\" button quadruple clicked",
|
"remote_button_quadruple_press": "\"{subtype}\" button quadruple clicked",
|
||||||
"remote_button_quintuple_press": "\"{subtype}\" button quintuple clicked",
|
"remote_button_quintuple_press": "\"{subtype}\" button quintuple clicked",
|
||||||
"remote_button_rotated": "Button rotated \"{subtype}\"",
|
"remote_button_rotated": "Button rotated \"{subtype}\"",
|
||||||
|
"remote_button_rotation_stopped": "Button rotation \"{subtype}\" stopped",
|
||||||
"remote_button_short_press": "\"{subtype}\" button pressed",
|
"remote_button_short_press": "\"{subtype}\" button pressed",
|
||||||
"remote_button_short_release": "\"{subtype}\" button released",
|
"remote_button_short_release": "\"{subtype}\" button released",
|
||||||
"remote_button_triple_press": "\"{subtype}\" button triple clicked",
|
"remote_button_triple_press": "\"{subtype}\" button triple clicked",
|
||||||
|
@ -31,6 +31,7 @@ CONF_TRIPLE_PRESS = "remote_button_triple_press"
|
|||||||
CONF_QUADRUPLE_PRESS = "remote_button_quadruple_press"
|
CONF_QUADRUPLE_PRESS = "remote_button_quadruple_press"
|
||||||
CONF_QUINTUPLE_PRESS = "remote_button_quintuple_press"
|
CONF_QUINTUPLE_PRESS = "remote_button_quintuple_press"
|
||||||
CONF_ROTATED = "remote_button_rotated"
|
CONF_ROTATED = "remote_button_rotated"
|
||||||
|
CONF_ROTATION_STOPPED = "remote_button_rotation_stopped"
|
||||||
CONF_SHAKE = "remote_gyro_activated"
|
CONF_SHAKE = "remote_gyro_activated"
|
||||||
|
|
||||||
CONF_TURN_ON = "turn_on"
|
CONF_TURN_ON = "turn_on"
|
||||||
@ -75,6 +76,17 @@ HUE_TAP_REMOTE = {
|
|||||||
(CONF_SHORT_PRESS, CONF_BUTTON_4): 18,
|
(CONF_SHORT_PRESS, CONF_BUTTON_4): 18,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SYMFONISK_SOUND_CONTROLLER_MODEL = "SYMFONISK Sound Controller"
|
||||||
|
SYMFONISK_SOUND_CONTROLLER = {
|
||||||
|
(CONF_SHORT_PRESS, CONF_TURN_ON): 1002,
|
||||||
|
(CONF_DOUBLE_PRESS, CONF_TURN_ON): 1004,
|
||||||
|
(CONF_TRIPLE_PRESS, CONF_TURN_ON): 1005,
|
||||||
|
(CONF_ROTATED, CONF_LEFT): 2001,
|
||||||
|
(CONF_ROTATION_STOPPED, CONF_LEFT): 2003,
|
||||||
|
(CONF_ROTATED, CONF_RIGHT): 3001,
|
||||||
|
(CONF_ROTATION_STOPPED, CONF_RIGHT): 3003,
|
||||||
|
}
|
||||||
|
|
||||||
TRADFRI_ON_OFF_SWITCH_MODEL = "TRADFRI on/off switch"
|
TRADFRI_ON_OFF_SWITCH_MODEL = "TRADFRI on/off switch"
|
||||||
TRADFRI_ON_OFF_SWITCH = {
|
TRADFRI_ON_OFF_SWITCH = {
|
||||||
(CONF_SHORT_PRESS, CONF_TURN_ON): 1002,
|
(CONF_SHORT_PRESS, CONF_TURN_ON): 1002,
|
||||||
@ -162,6 +174,7 @@ AQARA_SQUARE_SWITCH = {
|
|||||||
REMOTES = {
|
REMOTES = {
|
||||||
HUE_DIMMER_REMOTE_MODEL: HUE_DIMMER_REMOTE,
|
HUE_DIMMER_REMOTE_MODEL: HUE_DIMMER_REMOTE,
|
||||||
HUE_TAP_REMOTE_MODEL: HUE_TAP_REMOTE,
|
HUE_TAP_REMOTE_MODEL: HUE_TAP_REMOTE,
|
||||||
|
SYMFONISK_SOUND_CONTROLLER_MODEL: SYMFONISK_SOUND_CONTROLLER,
|
||||||
TRADFRI_ON_OFF_SWITCH_MODEL: TRADFRI_ON_OFF_SWITCH,
|
TRADFRI_ON_OFF_SWITCH_MODEL: TRADFRI_ON_OFF_SWITCH,
|
||||||
TRADFRI_OPEN_CLOSE_REMOTE_MODEL: TRADFRI_OPEN_CLOSE_REMOTE,
|
TRADFRI_OPEN_CLOSE_REMOTE_MODEL: TRADFRI_OPEN_CLOSE_REMOTE,
|
||||||
TRADFRI_REMOTE_MODEL: TRADFRI_REMOTE,
|
TRADFRI_REMOTE_MODEL: TRADFRI_REMOTE,
|
||||||
@ -200,7 +213,7 @@ async def async_attach_trigger(hass, config, action, automation_info):
|
|||||||
|
|
||||||
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
|
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
|
||||||
|
|
||||||
if device.model not in REMOTES and trigger not in REMOTES[device.model]:
|
if device.model not in REMOTES or trigger not in REMOTES[device.model]:
|
||||||
raise InvalidDeviceAutomationConfig
|
raise InvalidDeviceAutomationConfig
|
||||||
|
|
||||||
trigger = REMOTES[device.model][trigger]
|
trigger = REMOTES[device.model][trigger]
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
"remote_button_quadruple_press": "\"{subtype}\" button quadruple clicked",
|
"remote_button_quadruple_press": "\"{subtype}\" button quadruple clicked",
|
||||||
"remote_button_quintuple_press": "\"{subtype}\" button quintuple clicked",
|
"remote_button_quintuple_press": "\"{subtype}\" button quintuple clicked",
|
||||||
"remote_button_rotated": "Button rotated \"{subtype}\"",
|
"remote_button_rotated": "Button rotated \"{subtype}\"",
|
||||||
|
"remote_button_rotation_stopped": "Button rotation \"{subtype}\" stopped",
|
||||||
"remote_gyro_activated": "Device shaken"
|
"remote_gyro_activated": "Device shaken"
|
||||||
},
|
},
|
||||||
"trigger_subtype": {
|
"trigger_subtype": {
|
||||||
|
@ -1,30 +1,13 @@
|
|||||||
"""deCONZ device automation tests."""
|
"""deCONZ device automation tests."""
|
||||||
from asynctest import patch
|
from copy import deepcopy
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import deconz
|
|
||||||
from homeassistant.components.deconz import device_trigger
|
from homeassistant.components.deconz import device_trigger
|
||||||
|
|
||||||
from tests.common import async_get_device_automations
|
from tests.common import async_get_device_automations
|
||||||
|
|
||||||
BRIDGEID = "0123456789"
|
from .test_gateway import ENTRY_CONFIG, DECONZ_WEB_REQUEST, setup_deconz_integration
|
||||||
|
|
||||||
ENTRY_CONFIG = {
|
SENSORS = {
|
||||||
deconz.config_flow.CONF_API_KEY: "ABCDEF",
|
|
||||||
deconz.config_flow.CONF_BRIDGEID: BRIDGEID,
|
|
||||||
deconz.config_flow.CONF_HOST: "1.2.3.4",
|
|
||||||
deconz.config_flow.CONF_PORT: 80,
|
|
||||||
}
|
|
||||||
|
|
||||||
DECONZ_CONFIG = {
|
|
||||||
"bridgeid": BRIDGEID,
|
|
||||||
"mac": "00:11:22:33:44:55",
|
|
||||||
"name": "deCONZ mock gateway",
|
|
||||||
"sw_version": "2.05.69",
|
|
||||||
"websocketport": 1234,
|
|
||||||
}
|
|
||||||
|
|
||||||
DECONZ_SENSOR = {
|
|
||||||
"1": {
|
"1": {
|
||||||
"config": {
|
"config": {
|
||||||
"alert": "none",
|
"alert": "none",
|
||||||
@ -46,37 +29,14 @@ DECONZ_SENSOR = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DECONZ_WEB_REQUEST = {"config": DECONZ_CONFIG, "sensors": DECONZ_SENSOR}
|
|
||||||
|
|
||||||
|
|
||||||
async def setup_deconz(hass, options):
|
|
||||||
"""Create the deCONZ gateway."""
|
|
||||||
config_entry = config_entries.ConfigEntry(
|
|
||||||
version=1,
|
|
||||||
domain=deconz.DOMAIN,
|
|
||||||
title="Mock Title",
|
|
||||||
data=ENTRY_CONFIG,
|
|
||||||
source="test",
|
|
||||||
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
|
|
||||||
system_options={},
|
|
||||||
options=options,
|
|
||||||
entry_id="1",
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"pydeconz.DeconzSession.async_get_state", return_value=DECONZ_WEB_REQUEST
|
|
||||||
):
|
|
||||||
await deconz.async_setup_entry(hass, config_entry)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
hass.config_entries._entries.append(config_entry)
|
|
||||||
|
|
||||||
return hass.data[deconz.DOMAIN][BRIDGEID]
|
|
||||||
|
|
||||||
|
|
||||||
async def test_get_triggers(hass):
|
async def test_get_triggers(hass):
|
||||||
"""Test triggers work."""
|
"""Test triggers work."""
|
||||||
gateway = await setup_deconz(hass, options={})
|
data = deepcopy(DECONZ_WEB_REQUEST)
|
||||||
|
data["sensors"] = deepcopy(SENSORS)
|
||||||
|
gateway = await setup_deconz_integration(
|
||||||
|
hass, ENTRY_CONFIG, options={}, get_state_response=data
|
||||||
|
)
|
||||||
device_id = gateway.events[0].device_id
|
device_id = gateway.events[0].device_id
|
||||||
triggers = await async_get_device_automations(hass, "trigger", device_id)
|
triggers = await async_get_device_automations(hass, "trigger", device_id)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user