Add device id to deconz_event (#43552)

This commit is contained in:
Robert Svensson 2020-11-23 09:22:44 +01:00 committed by GitHub
parent a4f7b7d784
commit ffe0c1cd58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -1,7 +1,7 @@
"""Representation of a deCONZ remote."""
from pydeconz.sensor import Switch
from homeassistant.const import CONF_EVENT, CONF_ID, CONF_UNIQUE_ID
from homeassistant.const import CONF_DEVICE_ID, CONF_EVENT, CONF_ID, CONF_UNIQUE_ID
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.util import slugify
@ -94,6 +94,9 @@ class DeconzEvent(DeconzBase):
CONF_EVENT: self._device.state,
}
if self.device_id:
data[CONF_DEVICE_ID] = self.device_id
if self._device.gesture is not None:
data[CONF_GESTURE] = self._device.gesture

View File

@ -77,6 +77,7 @@ async def test_deconz_events(hass):
"id": "switch_1",
"unique_id": "00:00:00:00:00:00:00:01",
"event": 2000,
"device_id": gateway.events[0].device_id,
}
gateway.api.sensors["3"].update({"state": {"buttonevent": 2000}})
@ -88,6 +89,7 @@ async def test_deconz_events(hass):
"unique_id": "00:00:00:00:00:00:00:03",
"event": 2000,
"gesture": 1,
"device_id": gateway.events[2].device_id,
}
gateway.api.sensors["4"].update({"state": {"gesture": 0}})
@ -99,6 +101,7 @@ async def test_deconz_events(hass):
"unique_id": "00:00:00:00:00:00:00:04",
"event": 1000,
"gesture": 0,
"device_id": gateway.events[3].device_id,
}
gateway.api.sensors["5"].update(
@ -113,6 +116,7 @@ async def test_deconz_events(hass):
"event": 6002,
"angle": 110,
"xy": [0.5982, 0.3897],
"device_id": gateway.events[4].device_id,
}
await hass.config_entries.async_unload(config_entry.entry_id)