Add device triggers for Hue remotes (#33476)
* Store device_registry entry id in HueEvent so it can be retrieved with that key when using device triggers * Add device_trigger for hue_event from hue remotes * supporting Hue dimmer switch & Hue Tap * State mapping and strings are copied from deCONZ * refactor mock_bridge for hue tests and also share `setup_bridge_for_sensors` for test_sensor_base and test_device_trigger. * Add tests for device triggers with hue remotes * Remove some triggers
This commit is contained in:
1 parent
400602a8b3
commit
71aaf2d809
8 files changed
+443
-120
No files matched your search
@@ -1,13 +1,9 @@
|
||||
"""Philips Hue lights platform tests."""
|
||||
import asyncio
|
||||
from collections import deque
|
||||
import logging
|
||||
from unittest.mock import Mock
|
||||
|
||||
import aiohue
|
||||
from aiohue.groups import Groups
|
||||
from aiohue.lights import Lights
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import hue
|
||||
@@ -175,48 +171,6 @@ LIGHT_GAMUT = color.GamutType(
|
||||
LIGHT_GAMUT_TYPE = "A"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_bridge(hass):
|
||||
"""Mock a Hue bridge."""
|
||||
bridge = Mock(
|
||||
hass=hass,
|
||||
available=True,
|
||||
authorized=True,
|
||||
allow_unreachable=False,
|
||||
allow_groups=False,
|
||||
api=Mock(),
|
||||
reset_jobs=[],
|
||||
spec=hue.HueBridge,
|
||||
)
|
||||
bridge.mock_requests = []
|
||||
# We're using a deque so we can schedule multiple responses
|
||||
# and also means that `popleft()` will blow up if we get more updates
|
||||
# than expected.
|
||||
bridge.mock_light_responses = deque()
|
||||
bridge.mock_group_responses = deque()
|
||||
|
||||
async def mock_request(method, path, **kwargs):
|
||||
kwargs["method"] = method
|
||||
kwargs["path"] = path
|
||||
bridge.mock_requests.append(kwargs)
|
||||
|
||||
if path == "lights":
|
||||
return bridge.mock_light_responses.popleft()
|
||||
if path == "groups":
|
||||
return bridge.mock_group_responses.popleft()
|
||||
return None
|
||||
|
||||
async def async_request_call(task):
|
||||
await task()
|
||||
|
||||
bridge.async_request_call = async_request_call
|
||||
bridge.api.config.apiversion = "9.9.9"
|
||||
bridge.api.lights = Lights({}, mock_request)
|
||||
bridge.api.groups = Groups({}, mock_request)
|
||||
|
||||
return bridge
|
||||
|
||||
|
||||
async def setup_bridge(hass, mock_bridge):
|
||||
"""Load the Hue light platform with the provided bridge."""
|
||||
hass.config.components.add(hue.DOMAIN)
|
||||
|
||||
Reference in new issue
Block a user