Cleanup dispatchers when unloading rfxtrx (#42803)

* Cleanup dispatchers

* Fix name

* Refactor code

* Fix typo in function description

* Fix pylint error

* Change function definition

* Move cleanup_callbacks data to domain
This commit is contained in:
Rob Bierbooms 2020-11-04 11:30:46 +01:00 committed by GitHub
parent 898f50386f
commit 1fe66df962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 24 deletions

View file

@ -6,12 +6,11 @@ from homeassistant.const import CONF_DEVICES, STATE_OPEN
from homeassistant.core import callback
from . import (
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
CONF_SIGNAL_REPETITIONS,
DEFAULT_SIGNAL_REPETITIONS,
SIGNAL_EVENT,
RfxtrxCommandEntity,
connect_auto_add,
get_device_id,
get_rfx_object,
)
@ -81,8 +80,7 @@ async def async_setup_entry(
async_add_entities([entity])
# Subscribe to main RFXtrx events
if discovery_info[CONF_AUTOMATIC_ADD]:
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, cover_update)
connect_auto_add(hass, discovery_info, cover_update)
class RfxtrxCover(RfxtrxCommandEntity, CoverEntity):