Create a base class for broadlink entities (#52132)
* Create a base class for broadlink entities * Update homeassistant/components/broadlink/entity.py Co-authored-by: Daniel Hjelseth Høyer <mail@dahoiv.net> * Update homeassistant/components/broadlink/entity.py * Update homeassistant/components/broadlink/entity.py Co-authored-by: Daniel Hjelseth Høyer <mail@dahoiv.net> * black, remove unused Co-authored-by: Daniel Hjelseth Høyer <mail@dahoiv.net>
This commit is contained in:
parent
d009f06a55
commit
22c8afe637
5 changed files with 46 additions and 69 deletions
32
homeassistant/components/broadlink/entity.py
Normal file
32
homeassistant/components/broadlink/entity.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
"""Broadlink entities."""
|
||||
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
class BroadlinkEntity:
|
||||
"""Representation of a Broadlink entity."""
|
||||
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the device."""
|
||||
self._device = device
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if the remote is available."""
|
||||
return self._device.update_manager.available
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device.unique_id)},
|
||||
"connections": {(dr.CONNECTION_NETWORK_MAC, self._device.mac_address)},
|
||||
"manufacturer": self._device.api.manufacturer,
|
||||
"model": self._device.api.model,
|
||||
"name": self._device.name,
|
||||
"sw_version": self._device.fw_version,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue