mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
deCONZ device automations (#26366)
* Early draft * Getting there * Working fully with Hue dimmer remote * Fix Balloobs comments * No side effects in constructor * Improve hue dimmer * Add Ikea remote control * Add xiaomi button support * Refactor getting deconz event * Added xiaomi devices and tradfri wireless dimmer * Resolve unique id from device id * Add Hue Tap and Tradfri on off switch * More triggers for ikea on off switch and Aqara double wall switch * Add support for Tradfri open close remote * Fix changes after rebase * Initial test * Change id to event_id * Fix translations and add subtypes * Try if tests pass without the new tests * Revert disabling tests Add new exception InvalidDeviceAutomationConfig * Ignore places calling remotes * Enable all gateway tests * Found the issue, now to identify which test creates it * Remove block till done * See if device automation test passes in azure * Register event to device registry * Enable test sensors * Skip deconz event tests currently failing * Added reason why skipping tests
This commit is contained in:
committed by
Paulus Schoutsen
parent
bee566f893
commit
c680c07c65
@@ -7,8 +7,8 @@ from homeassistant.helpers.entity import Entity
|
||||
from .const import DOMAIN as DECONZ_DOMAIN
|
||||
|
||||
|
||||
class DeconzDevice(Entity):
|
||||
"""Representation of a deCONZ device."""
|
||||
class DeconzBase:
|
||||
"""Common base for deconz entities and events."""
|
||||
|
||||
def __init__(self, device, gateway):
|
||||
"""Set up device and add update callback to get data from websocket."""
|
||||
@@ -16,6 +16,47 @@ class DeconzDevice(Entity):
|
||||
self.gateway = gateway
|
||||
self.listeners = []
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique identifier for this device."""
|
||||
return self._device.uniqueid
|
||||
|
||||
@property
|
||||
def serial(self):
|
||||
"""Return a serial number for this device."""
|
||||
if self.unique_id is None or self.unique_id.count(":") != 7:
|
||||
return None
|
||||
|
||||
return self.unique_id.split("-", 1)[0]
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return a device description for device registry."""
|
||||
if self.serial is None:
|
||||
return None
|
||||
|
||||
bridgeid = self.gateway.api.config.bridgeid
|
||||
|
||||
return {
|
||||
"connections": {(CONNECTION_ZIGBEE, self.serial)},
|
||||
"identifiers": {(DECONZ_DOMAIN, self.serial)},
|
||||
"manufacturer": self._device.manufacturer,
|
||||
"model": self._device.modelid,
|
||||
"name": self._device.name,
|
||||
"sw_version": self._device.swversion,
|
||||
"via_device": (DECONZ_DOMAIN, bridgeid),
|
||||
}
|
||||
|
||||
|
||||
class DeconzDevice(DeconzBase, Entity):
|
||||
"""Representation of a deCONZ device."""
|
||||
|
||||
def __init__(self, device, gateway):
|
||||
"""Set up device and add update callback to get data from websocket."""
|
||||
super().__init__(device, gateway)
|
||||
|
||||
self.unsub_dispatcher = None
|
||||
|
||||
@property
|
||||
def entity_registry_enabled_default(self):
|
||||
"""Return if the entity should be enabled when first added to the entity registry."""
|
||||
@@ -54,41 +95,17 @@ class DeconzDevice(Entity):
|
||||
"""Update the device's state."""
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return self._device.name
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique identifier for this device."""
|
||||
return self._device.uniqueid
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if device is available."""
|
||||
return self.gateway.available and self._device.reachable
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return self._device.name
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return a device description for device registry."""
|
||||
if self._device.uniqueid is None or self._device.uniqueid.count(":") != 7:
|
||||
return None
|
||||
|
||||
serial = self._device.uniqueid.split("-", 1)[0]
|
||||
bridgeid = self.gateway.api.config.bridgeid
|
||||
|
||||
return {
|
||||
"connections": {(CONNECTION_ZIGBEE, serial)},
|
||||
"identifiers": {(DECONZ_DOMAIN, serial)},
|
||||
"manufacturer": self._device.manufacturer,
|
||||
"model": self._device.modelid,
|
||||
"name": self._device.name,
|
||||
"sw_version": self._device.swversion,
|
||||
"via_device": (DECONZ_DOMAIN, bridgeid),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user