Skip to content

Commit

Permalink
Unsubscribes the dispatch signal listener
Browse files Browse the repository at this point in the history
  • Loading branch information
JohNan committed Jun 17, 2019
1 parent 5b4ce0f commit 2a3d940
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions homeassistant/components/plaato/__init__.py
Expand Up @@ -33,6 +33,7 @@
ATTR_BATCH_VOLUME = 'batch_volume'

SENSOR_UPDATE = '{}_sensor_update'.format(DOMAIN)
SENSOR_DATA_KEY = '{}.{}'.format(DOMAIN, SENSOR)

WEBHOOK_SCHEMA = vol.Schema({
vol.Required(ATTR_DEVICE_NAME): cv.string,
Expand Down Expand Up @@ -74,6 +75,7 @@ async def async_setup_entry(hass, entry):
async def async_unload_entry(hass, entry):
"""Unload a config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
hass.data[SENSOR_DATA_KEY]()

await hass.config_entries.async_forward_entry_unload(entry, SENSOR)
return True
Expand Down
7 changes: 2 additions & 5 deletions homeassistant/components/plaato/sensor.py
Expand Up @@ -8,13 +8,10 @@
from . import (
ATTR_ABV, ATTR_BATCH_VOLUME, ATTR_BPM, ATTR_CO2_VOLUME, ATTR_TEMP,
ATTR_TEMP_UNIT, ATTR_VOLUME_UNIT, DOMAIN as PLAATO_DOMAIN,
PLAATO_DEVICE_ATTRS, PLAATO_DEVICE_SENSORS, SENSOR as SENSOR_DOMAIN,
SENSOR_UPDATE)
PLAATO_DEVICE_ATTRS, PLAATO_DEVICE_SENSORS, SENSOR_DATA_KEY, SENSOR_UPDATE)

_LOGGER = logging.getLogger(__name__)

DATA_KEY = '{}.{}'.format(PLAATO_DOMAIN, SENSOR_DOMAIN)


async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
Expand Down Expand Up @@ -50,7 +47,7 @@ async def _update_sensor(device_id):
for entity in devices[device_id]:
entity.async_schedule_update_ha_state()

hass.data[DATA_KEY] = async_dispatcher_connect(
hass.data[SENSOR_DATA_KEY] = async_dispatcher_connect(
hass, SENSOR_UPDATE, _update_sensor
)

Expand Down

0 comments on commit 2a3d940

Please sign in to comment.