1
1
"""Custom Integration to setup UI Lovelace Minimalist."""
2
+
2
3
from __future__ import annotations
3
4
4
5
import logging
5
6
from typing import Any
6
7
7
8
from aiogithubapi import AIOGitHubAPIException , GitHubAPI
8
- from homeassistant .components import frontend
9
+ from homeassistant .components . frontend import async_remove_panel
9
10
from homeassistant .config_entries import SOURCE_IMPORT , ConfigEntry
10
- from homeassistant .core import Config , HomeAssistant
11
+ from homeassistant .core import HomeAssistant
11
12
from homeassistant .helpers .aiohttp_client import async_get_clientsession
12
13
from homeassistant .loader import async_get_integration
13
14
@@ -64,7 +65,6 @@ async def async_initialize_integration(
64
65
65
66
ulm .integration = integration
66
67
ulm .version = integration .version
67
- ulm .session = clientsession
68
68
ulm .hass = hass
69
69
ulm .system .running = True
70
70
ulm .githubapi = GitHubAPI (
@@ -89,11 +89,10 @@ async def async_startup():
89
89
await ulm .fetch_cards ()
90
90
await ulm .configure_community_cards ()
91
91
92
- if (
93
- not await ulm .configure_ulm ()
94
- or not await ulm .configure_plugins ()
95
- or not await ulm .configure_dashboard ()
96
- ):
92
+ ResponseConfigure = await ulm .configure_ulm ()
93
+ ResponsePlugins = await ulm .configure_plugins ()
94
+ ResponseDashboard = await ulm .configure_dashboard ()
95
+ if not ResponseConfigure or not ResponsePlugins or not ResponseDashboard :
97
96
return False
98
97
99
98
ulm .enable_ulm ()
@@ -112,15 +111,15 @@ async def async_startup():
112
111
return True
113
112
114
113
115
- async def async_setup (hass : HomeAssistant , config : Config ):
114
+ async def async_setup (hass : HomeAssistant , config : dict ):
116
115
"""Set up this integration using UI."""
117
116
return await async_initialize_integration (hass = hass , config = config )
118
117
119
118
120
119
async def async_setup_entry (hass : HomeAssistant , config_entry : ConfigEntry ) -> bool :
121
120
"""Set up this integration using UI."""
122
121
123
- config_entry .add_update_listener (async_reload_entry )
122
+ config_entry .add_update_listener (config_entry_update_listener )
124
123
return await async_initialize_integration (hass = hass , config_entry = config_entry )
125
124
126
125
@@ -131,11 +130,27 @@ async def async_remove_entry(hass: HomeAssistant, config_entry: ConfigEntry):
131
130
# TODO cleanup:
132
131
# - themes
133
132
# - blueprints
134
- frontend . async_remove_panel (hass , "ui-lovelace-minimalist" )
133
+ async_remove_panel (hass , "ui-lovelace-minimalist" )
135
134
136
135
137
136
async def async_reload_entry (hass : HomeAssistant , config_entry : ConfigEntry ) -> None :
138
137
"""Reload Integration."""
139
138
_LOGGER .debug ("Reload the config entry" )
140
139
141
140
await async_setup_entry (hass , config_entry )
141
+
142
+
143
+ async def config_entry_update_listener (
144
+ hass : HomeAssistant , config_entry : ConfigEntry
145
+ ) -> None :
146
+ """Update listener, called when the config entry options are changed."""
147
+ _LOGGER .debug ("Start config_entry_update async_reload" )
148
+
149
+ await hass .config_entries .async_reload (config_entry .entry_id )
150
+
151
+
152
+ async def async_unload_entry (hass : HomeAssistant , config_entry : ConfigEntry ):
153
+ """Unload Integration."""
154
+ _LOGGER .debug ("Unload the config entry" )
155
+
156
+ return await async_initialize_integration (hass = hass , config_entry = config_entry )
0 commit comments