Use attrs instead of properties for directv (#51918)
* Use attrs instead of properties for directv * Update __init__.py * Create entity.py * Update media_player.py * Update remote.py * Update media_player.py * Update remote.py * Update media_player.py * Update remote.py * Update entity.py * Update __init__.py * Update media_player.py * Update remote.py * Update media_player.py * Update media_player.py
This commit is contained in:
parent
2351f2d95e
commit
4e88b44286
4 changed files with 68 additions and 108 deletions
39
homeassistant/components/directv/entity.py
Normal file
39
homeassistant/components/directv/entity.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
"""Base DirecTV Entity."""
|
||||
from __future__ import annotations
|
||||
|
||||
from directv import DIRECTV
|
||||
|
||||
from homeassistant.const import ATTR_NAME
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from .const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_SOFTWARE_VERSION,
|
||||
ATTR_VIA_DEVICE,
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
|
||||
class DIRECTVEntity(Entity):
|
||||
"""Defines a base DirecTV entity."""
|
||||
|
||||
def __init__(self, *, dtv: DIRECTV, address: str = "0") -> None:
|
||||
"""Initialize the DirecTV entity."""
|
||||
self._address = address
|
||||
self._device_id = address if address != "0" else dtv.device.info.receiver_id
|
||||
self._is_client = address != "0"
|
||||
self.dtv = dtv
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information about this DirecTV receiver."""
|
||||
return {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, self._device_id)},
|
||||
ATTR_NAME: self.name,
|
||||
ATTR_MANUFACTURER: self.dtv.device.info.brand,
|
||||
ATTR_MODEL: None,
|
||||
ATTR_SOFTWARE_VERSION: self.dtv.device.info.version,
|
||||
ATTR_VIA_DEVICE: (DOMAIN, self.dtv.device.info.receiver_id),
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue