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
7 changed files with 32 additions and 24 deletions

View File

@@ -20,11 +20,10 @@ from homeassistant.const import (
from homeassistant.core import callback
from . import (
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
DATA_TYPES,
SIGNAL_EVENT,
RfxtrxEntity,
connect_auto_add,
get_device_id,
get_rfx_object,
)
@@ -127,8 +126,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, sensor_update)
connect_auto_add(hass, discovery_info, sensor_update)
class RfxtrxSensor(RfxtrxEntity):