mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-08 16:34:28 +02:00
Redid integration remove to unload platform
This commit is contained in:
parent
3b95198ad8
commit
a918a039ab
2 changed files with 16 additions and 7 deletions
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
|||
)
|
||||
|
||||
from .const import (
|
||||
PLATFORMS,
|
||||
DOMAIN,
|
||||
DATA_CLIENT,
|
||||
RUN_SCRIPT_COMMAND,
|
||||
|
@ -104,12 +105,12 @@ async def async_setup_entry(hass, config_entry):
|
|||
async def async_unload_entry(hass, config_entry):
|
||||
"""Unload a config entry."""
|
||||
controller = hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id]
|
||||
await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
|
||||
await hass.config_entries.async_forward_entry_unload(config_entry, "binary_sensor")
|
||||
await hass.config_entries.async_forward_entry_unload(config_entry, "device_tracker")
|
||||
await hass.config_entries.async_forward_entry_unload(config_entry, "switch")
|
||||
await hass.config_entries.async_forward_entry_unload(config_entry, "button")
|
||||
hass.services.async_remove(DOMAIN, RUN_SCRIPT_COMMAND)
|
||||
await controller.async_reset()
|
||||
hass.services.async_remove(DOMAIN, RUN_SCRIPT_COMMAND)
|
||||
hass.data[DOMAIN][DATA_CLIENT].pop(config_entry.entry_id)
|
||||
return True
|
||||
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, PLATFORMS
|
||||
)
|
||||
|
||||
return unload_ok
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
"""Constants used by the Mikrotik Router component and platforms."""
|
||||
from homeassistant.const import Platform
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.SENSOR,
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.DEVICE_TRACKER,
|
||||
Platform.SWITCH,
|
||||
Platform.BUTTON,
|
||||
]
|
||||
DOMAIN = "mikrotik_router"
|
||||
DEFAULT_NAME = "Mikrotik Router"
|
||||
DATA_CLIENT = "client"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue