Make sensor and binary_sensor inherit from base class (#37946)

* Make sensor and binary_sensor inherit from base class

* Drop several pointless public properties

* Make sure base function has same parameters

* Drop pass

* Missed one

* Adjust inherit order
This commit is contained in:
Joakim Plate 2020-07-18 13:43:38 +02:00 committed by GitHub
parent b030ed1adf
commit f173805c2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 216 deletions

View file

@ -4,14 +4,13 @@ import logging
from homeassistant.components.cover import CoverEntity
from homeassistant.const import CONF_DEVICES
from homeassistant.core import callback
from homeassistant.helpers.restore_state import RestoreEntity
from . import (
CONF_AUTOMATIC_ADD,
CONF_SIGNAL_REPETITIONS,
DEFAULT_SIGNAL_REPETITIONS,
SIGNAL_EVENT,
RfxtrxDevice,
RfxtrxCommandEntity,
get_device_id,
get_rfx_object,
)
@ -79,24 +78,9 @@ async def async_setup_entry(
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, cover_update)
class RfxtrxCover(RfxtrxDevice, CoverEntity, RestoreEntity):
class RfxtrxCover(RfxtrxCommandEntity, CoverEntity):
"""Representation of a RFXtrx cover."""
async def async_added_to_hass(self):
"""Restore RFXtrx cover device state (OPEN/CLOSE)."""
await super().async_added_to_hass()
self.async_on_remove(
self.hass.helpers.dispatcher.async_dispatcher_connect(
SIGNAL_EVENT, self._handle_event
)
)
@property
def should_poll(self):
"""Return the polling state. No polling available in RFXtrx cover."""
return False
@property
def is_closed(self):
"""Return if the cover is closed."""