mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Expose angle and xy attributes in deCONZ event if present (#39822)
These attribute are used by the color wheel on the Müller Licht tint remote control.
This commit is contained in:
parent
749d3c360a
commit
74cef6966d
@ -44,4 +44,6 @@ POWER_PLUGS = ["On/Off light", "On/Off plug-in unit", "Smart plug"]
|
||||
SIRENS = ["Warning device"]
|
||||
SWITCH_TYPES = POWER_PLUGS + SIRENS
|
||||
|
||||
CONF_ANGLE = "angle"
|
||||
CONF_GESTURE = "gesture"
|
||||
CONF_XY = "xy"
|
||||
|
@ -3,7 +3,7 @@ from homeassistant.const import CONF_EVENT, CONF_ID, CONF_UNIQUE_ID
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.util import slugify
|
||||
|
||||
from .const import CONF_GESTURE, LOGGER
|
||||
from .const import CONF_ANGLE, CONF_GESTURE, CONF_XY, LOGGER
|
||||
from .deconz_device import DeconzBase
|
||||
|
||||
CONF_DECONZ_EVENT = "deconz_event"
|
||||
@ -52,6 +52,12 @@ class DeconzEvent(DeconzBase):
|
||||
if self._device.gesture is not None:
|
||||
data[CONF_GESTURE] = self._device.gesture
|
||||
|
||||
if self._device.angle is not None:
|
||||
data[CONF_ANGLE] = self._device.angle
|
||||
|
||||
if self._device.xy is not None:
|
||||
data[CONF_XY] = self._device.xy
|
||||
|
||||
self.gateway.hass.bus.async_fire(CONF_DECONZ_EVENT, data)
|
||||
|
||||
async def async_update_device_registry(self):
|
||||
|
@ -40,6 +40,14 @@ SENSORS = {
|
||||
"config": {"battery": 100},
|
||||
"uniqueid": "00:00:00:00:00:00:00:04-00",
|
||||
},
|
||||
"5": {
|
||||
"id": "ZHA remote 1 id",
|
||||
"name": "ZHA remote 1",
|
||||
"type": "ZHASwitch",
|
||||
"state": {"angle": 0, "buttonevent": 1000, "xy": [0.0, 0.0]},
|
||||
"config": {"group": "4,5,6", "reachable": True, "on": True},
|
||||
"uniqueid": "00:00:00:00:00:00:00:05-00",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +61,7 @@ async def test_deconz_events(hass):
|
||||
assert "sensor.switch_2" not in gateway.deconz_ids
|
||||
assert "sensor.switch_2_battery_level" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 3
|
||||
assert len(gateway.events) == 4
|
||||
assert len(gateway.events) == 5
|
||||
|
||||
switch_1 = hass.states.get("sensor.switch_1")
|
||||
assert switch_1 is None
|
||||
@ -101,6 +109,20 @@ async def test_deconz_events(hass):
|
||||
"gesture": 0,
|
||||
}
|
||||
|
||||
gateway.api.sensors["5"].update(
|
||||
{"state": {"buttonevent": 6002, "angle": 110, "xy": [0.5982, 0.3897]}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(events) == 4
|
||||
assert events[3].data == {
|
||||
"id": "zha_remote_1",
|
||||
"unique_id": "00:00:00:00:00:00:00:05",
|
||||
"event": 6002,
|
||||
"angle": 110,
|
||||
"xy": [0.5982, 0.3897],
|
||||
}
|
||||
|
||||
await gateway.async_reset()
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user