Refactor Tradfri base class (#27589)
* Refactor Tradfri base class * Clarify doc * Fix pylint * Review fix * Movepull/27623/head
parent
9fb0812ce5
commit
3454b6fa87
|
@ -10,8 +10,11 @@ from .const import DOMAIN
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TradfriBaseDevice(Entity):
|
||||
"""Base class for a TRADFRI device."""
|
||||
class TradfriBaseClass(Entity):
|
||||
"""Base class for IKEA TRADFRI.
|
||||
|
||||
All devices and groups should ultimately inherit from this class.
|
||||
"""
|
||||
|
||||
def __init__(self, device, api, gateway_id):
|
||||
"""Initialize a device."""
|
||||
|
@ -54,20 +57,6 @@ class TradfriBaseDevice(Entity):
|
|||
"""Return True if entity is available."""
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return the device info."""
|
||||
info = self._device.device_info
|
||||
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device.id)},
|
||||
"manufacturer": info.manufacturer,
|
||||
"model": info.model_number,
|
||||
"name": self._name,
|
||||
"sw_version": info.firmware_version,
|
||||
"via_device": (DOMAIN, self._gateway_id),
|
||||
}
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the display name of this device."""
|
||||
|
@ -94,3 +83,24 @@ class TradfriBaseDevice(Entity):
|
|||
self._device = device
|
||||
self._name = device.name
|
||||
self._available = device.reachable
|
||||
|
||||
|
||||
class TradfriBaseDevice(TradfriBaseClass):
|
||||
"""Base class for a TRADFRI device.
|
||||
|
||||
All devices should inherit from this class.
|
||||
"""
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return the device info."""
|
||||
info = self._device.device_info
|
||||
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device.id)},
|
||||
"manufacturer": info.manufacturer,
|
||||
"model": info.model_number,
|
||||
"name": self._name,
|
||||
"sw_version": info.firmware_version,
|
||||
"via_device": (DOMAIN, self._gateway_id),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue