Skip to content

Commit

Permalink
Fix: Warning in HA 2024.07.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajNyiri committed Jul 4, 2024
1 parent f69c214 commit a0d25e5
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions custom_components/lights_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ async def setupConnection(hass, address, config_entry):
)
if ble_device:
LOGGER.debug("BLE Device found, connecting...")
hass.data[DOMAIN][config_entry.entry_id]["connection"][
"client"
] = await establish_connection(
BleakClientWithServiceCache,
ble_device,
name=address,
disconnected_callback=disconnect_handler(
hass.data[DOMAIN][config_entry.entry_id]
),
use_services_cache=True,
max_attempts=1,
hass.data[DOMAIN][config_entry.entry_id]["connection"]["client"] = (
await establish_connection(
BleakClientWithServiceCache,
ble_device,
name=address,
disconnected_callback=disconnect_handler(
hass.data[DOMAIN][config_entry.entry_id]
),
use_services_cache=True,
max_attempts=1,
)
)
hass.data[DOMAIN][config_entry.entry_id]["connection"][
"connected"
Expand All @@ -49,9 +49,9 @@ async def setupConnection(hass, address, config_entry):
client = hass.data[DOMAIN][config_entry.entry_id]["connection"][
"client"
]
hass.data[DOMAIN][config_entry.entry_id]["connection"][
"service"
] = client.services.get_service(SERVICE)
hass.data[DOMAIN][config_entry.entry_id]["connection"]["service"] = (
client.services.get_service(SERVICE)
)
communicationService = hass.data[DOMAIN][config_entry.entry_id][
"connection"
]["service"]
Expand Down Expand Up @@ -84,9 +84,15 @@ async def setupConnection(hass, address, config_entry):


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await hass.config_entries.async_forward_entry_unload(entry, "switch")
await hass.config_entries.async_forward_entry_unload(entry, "light")
await hass.config_entries.async_forward_entry_unload(entry, "number")
await hass.config_entries.async_unload_platforms(
entry,
[
"switch",
"light",
"number",
],
)

if hass.data[DOMAIN][entry.entry_id]["connection"]["connected"]:
client = hass.data[DOMAIN][entry.entry_id]["connection"]["client"]
await client.disconnect()
Expand Down Expand Up @@ -145,14 +151,10 @@ async def async_update_data():
)
hass.data[DOMAIN][entry.entry_id]["coordinator"] = lightsAppCoordinator

hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "light")
)
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "switch")
)
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "number")
await hass.async_create_task(
hass.config_entries.async_forward_entry_setups(
entry, ["light", "switch", "number"]
)
)
return True
raise ConfigEntryNotReady()

0 comments on commit a0d25e5

Please sign in to comment.