mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Explicitly pass in the config_entry in traccar_server coordinator (#137893)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
7986e0fec1
commit
8a7ee039d1
@ -21,13 +21,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
|
|
||||||
from .const import (
|
from .const import CONF_EVENTS, DOMAIN
|
||||||
CONF_CUSTOM_ATTRIBUTES,
|
|
||||||
CONF_EVENTS,
|
|
||||||
CONF_MAX_ACCURACY,
|
|
||||||
CONF_SKIP_ACCURACY_FILTER_FOR,
|
|
||||||
DOMAIN,
|
|
||||||
)
|
|
||||||
from .coordinator import TraccarServerCoordinator
|
from .coordinator import TraccarServerCoordinator
|
||||||
|
|
||||||
PLATFORMS: list[Platform] = [
|
PLATFORMS: list[Platform] = [
|
||||||
@ -47,6 +41,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
)
|
)
|
||||||
coordinator = TraccarServerCoordinator(
|
coordinator = TraccarServerCoordinator(
|
||||||
hass=hass,
|
hass=hass,
|
||||||
|
config_entry=entry,
|
||||||
client=ApiClient(
|
client=ApiClient(
|
||||||
client_session=client_session,
|
client_session=client_session,
|
||||||
host=entry.data[CONF_HOST],
|
host=entry.data[CONF_HOST],
|
||||||
@ -56,10 +51,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
ssl=entry.data[CONF_SSL],
|
ssl=entry.data[CONF_SSL],
|
||||||
verify_ssl=entry.data[CONF_VERIFY_SSL],
|
verify_ssl=entry.data[CONF_VERIFY_SSL],
|
||||||
),
|
),
|
||||||
events=entry.options.get(CONF_EVENTS, []),
|
|
||||||
max_accuracy=entry.options.get(CONF_MAX_ACCURACY, 0.0),
|
|
||||||
skip_accuracy_filter_for=entry.options.get(CONF_SKIP_ACCURACY_FILTER_FOR, []),
|
|
||||||
custom_attributes=entry.options.get(CONF_CUSTOM_ATTRIBUTES, []),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
@ -22,7 +22,15 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
|||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from .const import DOMAIN, EVENTS, LOGGER
|
from .const import (
|
||||||
|
CONF_CUSTOM_ATTRIBUTES,
|
||||||
|
CONF_EVENTS,
|
||||||
|
CONF_MAX_ACCURACY,
|
||||||
|
CONF_SKIP_ACCURACY_FILTER_FOR,
|
||||||
|
DOMAIN,
|
||||||
|
EVENTS,
|
||||||
|
LOGGER,
|
||||||
|
)
|
||||||
from .helpers import get_device, get_first_geofence
|
from .helpers import get_device, get_first_geofence
|
||||||
|
|
||||||
|
|
||||||
@ -46,25 +54,24 @@ class TraccarServerCoordinator(DataUpdateCoordinator[TraccarServerCoordinatorDat
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
client: ApiClient,
|
client: ApiClient,
|
||||||
*,
|
|
||||||
events: list[str],
|
|
||||||
max_accuracy: float,
|
|
||||||
skip_accuracy_filter_for: list[str],
|
|
||||||
custom_attributes: list[str],
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize global Traccar Server data updater."""
|
"""Initialize global Traccar Server data updater."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass=hass,
|
hass=hass,
|
||||||
logger=LOGGER,
|
logger=LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=None,
|
update_interval=None,
|
||||||
)
|
)
|
||||||
self.client = client
|
self.client = client
|
||||||
self.custom_attributes = custom_attributes
|
self.custom_attributes = config_entry.options.get(CONF_CUSTOM_ATTRIBUTES, [])
|
||||||
self.events = events
|
self.events = config_entry.options.get(CONF_EVENTS, [])
|
||||||
self.max_accuracy = max_accuracy
|
self.max_accuracy = config_entry.options.get(CONF_MAX_ACCURACY, 0.0)
|
||||||
self.skip_accuracy_filter_for = skip_accuracy_filter_for
|
self.skip_accuracy_filter_for = config_entry.options.get(
|
||||||
|
CONF_SKIP_ACCURACY_FILTER_FOR, []
|
||||||
|
)
|
||||||
self._geofences: list[GeofenceModel] = []
|
self._geofences: list[GeofenceModel] = []
|
||||||
self._last_event_import: datetime | None = None
|
self._last_event_import: datetime | None = None
|
||||||
self._should_log_subscription_error: bool = True
|
self._should_log_subscription_error: bool = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user