mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Fix lingering timers in analytics (#91363)
This commit is contained in:
parent
7061b104a9
commit
e39f0320df
@ -5,7 +5,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components import websocket_api
|
from homeassistant.components import websocket_api
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
||||||
from homeassistant.core import Event, HomeAssistant, callback
|
from homeassistant.core import Event, HassJob, HomeAssistant, callback
|
||||||
from homeassistant.helpers.event import async_call_later, async_track_time_interval
|
from homeassistant.helpers.event import async_call_later, async_track_time_interval
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
@ -24,11 +24,23 @@ async def async_setup(hass: HomeAssistant, _: ConfigType) -> bool:
|
|||||||
def start_schedule(_event: Event) -> None:
|
def start_schedule(_event: Event) -> None:
|
||||||
"""Start the send schedule after the started event."""
|
"""Start the send schedule after the started event."""
|
||||||
# Wait 15 min after started
|
# Wait 15 min after started
|
||||||
async_call_later(hass, 900, analytics.send_analytics)
|
async_call_later(
|
||||||
|
hass,
|
||||||
|
900,
|
||||||
|
HassJob(
|
||||||
|
analytics.send_analytics,
|
||||||
|
name="analytics schedule",
|
||||||
|
cancel_on_shutdown=True,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
# Send every day
|
# Send every day
|
||||||
async_track_time_interval(
|
async_track_time_interval(
|
||||||
hass, analytics.send_analytics, INTERVAL, name="analytics daily"
|
hass,
|
||||||
|
analytics.send_analytics,
|
||||||
|
INTERVAL,
|
||||||
|
name="analytics daily",
|
||||||
|
cancel_on_shutdown=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, start_schedule)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, start_schedule)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user