Update to to latest georideapilib

This commit is contained in:
Matthieu DUVAL
2023-02-27 18:02:27 +01:00
parent b8c8bcba14
commit 7ea6c96331
5 changed files with 86 additions and 30 deletions

View File

@@ -44,11 +44,8 @@ from .const import (
SIREN_ACTIVATION_DELAY
)
_LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = vol.Schema(
{
vol.Required(DOMAIN, default={}): {
@@ -59,7 +56,6 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass, config):
"""Setup GeoRide component."""
hass.data[DOMAIN] = {"config": config[DOMAIN], "devices": {}, "unsub": None}
@@ -76,7 +72,6 @@ async def async_setup(hass, config):
# Return boolean to indicate that initialization was successful.
return True
async def async_setup_entry(hass, entry):
"""Set up GeoRide entry."""
config = hass.data[DOMAIN]["config"]
@@ -111,7 +106,7 @@ async def async_setup_entry(hass, entry):
return True
async def async_unload_entry(hass, entry):
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload an GeoRide config entry."""
await hass.config_entries.async_forward_entry_unload(entry, "device_tracker")
@@ -120,9 +115,22 @@ async def async_unload_entry(hass, entry):
await hass.config_entries.async_forward_entry_unload(entry, "binary_sensor")
await hass.config_entries.async_forward_entry_unload(entry, "siren")
context = hass.data[DOMAIN]["context"]
context.socket.disconnect() // Disconnect only if all devices is disabled
return True
async def async_remove_config_entry_device(hass: HomeAssistant, config_entry: ConfigEntry, device_entry: DeviceEntry) -> bool:
"""Remove an GeoRide device entry."""
await hass.config_entries.async_remove_config_entry_device(device_entry, "device_tracker")
await hass.config_entries.async_remove_config_entry_device(device_entry, "switch")
await hass.config_entries.async_remove_config_entry_device(device_entry, "sensor")
await hass.config_entries.async_remove_config_entry_device(device_entry, "binary_sensor")
await hass.config_entries.async_remove_config_entry_device(device_entry, "siren")
context = hass.data[DOMAIN]["context"]
context.socket.disconnect()
# context.socket.disconnect()
return True