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:
J. Nick Koston 2021-06-24 19:39:21 -10:00 committed by GitHub
parent d009f06a55
commit 22c8afe637
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 69 deletions

View 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,
}