New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deCONZ allow unloading of config entry #14115
deCONZ allow unloading of config entry #14115
Conversation
hass.services.async_remove(DOMAIN, SERVICE_DECONZ) | ||
deconz.close() | ||
for component in ['binary_sensor', 'light', 'scene', 'sensor']: | ||
hass.async_add_job(hass.config_entries.async_forward_entry_unload( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason to async_add_job
, you can just await them.
@@ -35,7 +35,7 @@ | |||
for sensor in sensors.values(): | |||
if sensor and sensor.type in DECONZ_SENSOR: | |||
if sensor.type in DECONZ_REMOTE: | |||
DeconzEvent(hass, sensor) | |||
hass.data[DATA_DECONZ_EVENT].append(DeconzEvent(hass, sensor)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@balloob do you want me to move the creation of the events and the class definition to be created by the setup entry method instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's just firing events, it should indeed be handled at the component level. It should not be done in the sensor platform.
@@ -82,6 +87,10 @@ | |||
for component in ['binary_sensor', 'light', 'scene', 'sensor']: | |||
hass.async_add_job(hass.config_entries.async_forward_entry_setup( | |||
config_entry, component)) | |||
|
|||
hass.data[DATA_DECONZ_EVENT] = [DeconzEvent(hass, sensor) | |||
for sensor in deconz.sensors.values() if sensor.type in DECONZ_REMOTE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
CONF_API_KEY, CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP) | ||
from homeassistant.core import callback | ||
from homeassistant.const import (CONF_API_KEY, CONF_EVENT, | ||
CONF_HOST, CONF_ID, CONF_PORT, EVENT_HOMEASSISTANT_STOP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
Looks good! Ok to merge when tests pass. Btw I've added some config entry documentation to https://developers.home-assistant.io and would love some feedback on it since you're the biggest user now 🙂 |
I'll have a look at it during the day 👍 |
Description:
Allow unloading deCONZ config entries and all its' entities
Checklist:
tox
. Your PR cannot be merged unless tests passIf the code does not interact with devices: