Use entity class attributes for anthemav (#52602)

This commit is contained in:
Robert Hillis 2021-07-08 05:42:07 -04:00 committed by GitHub
parent 1dd4ba5fcd
commit 7d0751df8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,11 +82,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
class AnthemAVR(MediaPlayerEntity):
"""Entity reading values from Anthem AVR protocol."""
_attr_should_poll = False
_attr_supported_features = SUPPORT_ANTHEMAV
def __init__(self, avr, name):
"""Initialize entity with transport."""
super().__init__()
self.avr = avr
self._name = name
self._attr_name = name or self._lookup("model")
def _lookup(self, propname, dval=None):
return getattr(self.avr.protocol, propname, dval)
@ -97,21 +100,6 @@ class AnthemAVR(MediaPlayerEntity):
async_dispatcher_connect(self.hass, DOMAIN, self.async_write_ha_state)
)
@property
def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_ANTHEMAV
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def name(self):
"""Return name of device."""
return self._name or self._lookup("model")
@property
def state(self):
"""Return state of power on/off."""