Update hunterdouglas_powerview to use CoordinatorEntity (#39463)

This commit is contained in:
J. Nick Koston 2020-08-30 13:28:09 -05:00 committed by GitHub
parent b57f33c41a
commit 9ec870c750
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 19 deletions

View file

@ -3,7 +3,7 @@
from aiopvapi.resources.shade import ATTR_TYPE
import homeassistant.helpers.device_registry as dr
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import (
DEVICE_FIRMWARE,
@ -20,31 +20,20 @@ from .const import (
)
class HDEntity(Entity):
class HDEntity(CoordinatorEntity):
"""Base class for hunter douglas entities."""
def __init__(self, coordinator, device_info, unique_id):
"""Initialize the entity."""
super().__init__()
self._coordinator = coordinator
super().__init__(coordinator)
self._unique_id = unique_id
self._device_info = device_info
@property
def available(self):
"""Return True if entity is available."""
return self._coordinator.last_update_success
@property
def unique_id(self):
"""Return the unique id."""
return self._unique_id
@property
def should_poll(self):
"""Return False, updates are controlled via coordinator."""
return False
@property
def device_info(self):
"""Return the device_info of the device."""