Adjust async_track_time_interval name argument (#90838)
Adjust async_track_time_interval naming
This commit is contained in:
parent
0f8060fd00
commit
c01b1eb013
15 changed files with 26 additions and 18 deletions
|
@ -28,7 +28,7 @@ async def async_setup(hass: HomeAssistant, _: ConfigType) -> bool:
|
||||||
|
|
||||||
# Send every day
|
# Send every day
|
||||||
async_track_time_interval(
|
async_track_time_interval(
|
||||||
hass, analytics.send_analytics, INTERVAL, "analytics daily"
|
hass, analytics.send_analytics, INTERVAL, name="analytics daily"
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, start_schedule)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, start_schedule)
|
||||||
|
|
|
@ -38,7 +38,10 @@ class AugustSubscriberMixin:
|
||||||
def _async_setup_listeners(self):
|
def _async_setup_listeners(self):
|
||||||
"""Create interval and stop listeners."""
|
"""Create interval and stop listeners."""
|
||||||
self._unsub_interval = async_track_time_interval(
|
self._unsub_interval = async_track_time_interval(
|
||||||
self._hass, self._async_refresh, self._update_interval, "august refresh"
|
self._hass,
|
||||||
|
self._async_refresh,
|
||||||
|
self._update_interval,
|
||||||
|
name="august refresh",
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -101,7 +101,7 @@ class BaseHaScanner(ABC):
|
||||||
self.hass,
|
self.hass,
|
||||||
self._async_scanner_watchdog,
|
self._async_scanner_watchdog,
|
||||||
SCANNER_WATCHDOG_INTERVAL,
|
SCANNER_WATCHDOG_INTERVAL,
|
||||||
f"{self.name} Bluetooth scanner watchdog",
|
name=f"{self.name} Bluetooth scanner watchdog",
|
||||||
)
|
)
|
||||||
|
|
||||||
@hass_callback
|
@hass_callback
|
||||||
|
@ -230,7 +230,7 @@ class BaseHaRemoteScanner(BaseHaScanner):
|
||||||
self.hass,
|
self.hass,
|
||||||
self._async_expire_devices,
|
self._async_expire_devices,
|
||||||
timedelta(seconds=30),
|
timedelta(seconds=30),
|
||||||
f"{self.name} Bluetooth scanner device expire",
|
name=f"{self.name} Bluetooth scanner device expire",
|
||||||
)
|
)
|
||||||
cancel_stop = self.hass.bus.async_listen(
|
cancel_stop = self.hass.bus.async_listen(
|
||||||
EVENT_HOMEASSISTANT_STOP, self._async_save_history
|
EVENT_HOMEASSISTANT_STOP, self._async_save_history
|
||||||
|
|
|
@ -276,7 +276,7 @@ class BluetoothManager:
|
||||||
self.hass,
|
self.hass,
|
||||||
self._async_check_unavailable,
|
self._async_check_unavailable,
|
||||||
timedelta(seconds=UNAVAILABLE_TRACK_SECONDS),
|
timedelta(seconds=UNAVAILABLE_TRACK_SECONDS),
|
||||||
"Bluetooth manager unavailable tracking",
|
name="Bluetooth manager unavailable tracking",
|
||||||
)
|
)
|
||||||
|
|
||||||
@hass_callback
|
@hass_callback
|
||||||
|
|
|
@ -177,7 +177,7 @@ class BondEntity(Entity):
|
||||||
self.hass,
|
self.hass,
|
||||||
self._async_update_if_bpup_not_alive,
|
self._async_update_if_bpup_not_alive,
|
||||||
_FALLBACK_SCAN_INTERVAL,
|
_FALLBACK_SCAN_INTERVAL,
|
||||||
f"Bond {self.entity_id} fallback polling",
|
name=f"Bond {self.entity_id} fallback polling",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
entity.async_write_ha_state()
|
entity.async_write_ha_state()
|
||||||
|
|
||||||
unsub = async_track_time_interval(
|
unsub = async_track_time_interval(
|
||||||
hass, update_tokens, TOKEN_CHANGE_INTERVAL, "Camera update tokens"
|
hass, update_tokens, TOKEN_CHANGE_INTERVAL, name="Camera update tokens"
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -475,7 +475,7 @@ def async_setup_scanner_platform(
|
||||||
hass,
|
hass,
|
||||||
async_device_tracker_scan,
|
async_device_tracker_scan,
|
||||||
interval,
|
interval,
|
||||||
f"device_tracker {platform} legacy scan",
|
name=f"device_tracker {platform} legacy scan",
|
||||||
)
|
)
|
||||||
hass.async_create_task(async_device_tracker_scan(None))
|
hass.async_create_task(async_device_tracker_scan(None))
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,10 @@ class NetworkWatcher(WatcherBase):
|
||||||
"""Start scanning for new devices on the network."""
|
"""Start scanning for new devices on the network."""
|
||||||
self._discover_hosts = DiscoverHosts()
|
self._discover_hosts = DiscoverHosts()
|
||||||
self._unsub = async_track_time_interval(
|
self._unsub = async_track_time_interval(
|
||||||
self.hass, self.async_start_discover, SCAN_INTERVAL, "DHCP network watcher"
|
self.hass,
|
||||||
|
self.async_start_discover,
|
||||||
|
SCAN_INTERVAL,
|
||||||
|
name="DHCP network watcher",
|
||||||
)
|
)
|
||||||
self.async_start_discover()
|
self.async_start_discover()
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,8 @@ class HKDevice:
|
||||||
self.hass,
|
self.hass,
|
||||||
self.async_update_available_state,
|
self.async_update_available_state,
|
||||||
timedelta(seconds=BLE_AVAILABILITY_CHECK_INTERVAL),
|
timedelta(seconds=BLE_AVAILABILITY_CHECK_INTERVAL),
|
||||||
f"HomeKit Controller {self.unique_id} BLE availability check poll",
|
name=f"HomeKit Controller {self.unique_id} BLE availability "
|
||||||
|
"check poll",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# BLE devices always get an RSSI sensor as well
|
# BLE devices always get an RSSI sensor as well
|
||||||
|
@ -290,7 +291,7 @@ class HKDevice:
|
||||||
self.hass,
|
self.hass,
|
||||||
self.async_request_update,
|
self.async_request_update,
|
||||||
self.pairing.poll_interval,
|
self.pairing.poll_interval,
|
||||||
f"HomeKit Controller {self.unique_id} availability check poll",
|
name=f"HomeKit Controller {self.unique_id} availability check poll",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@ class Recorder(threading.Thread):
|
||||||
self.hass,
|
self.hass,
|
||||||
self._async_check_queue,
|
self._async_check_queue,
|
||||||
timedelta(minutes=10),
|
timedelta(minutes=10),
|
||||||
"Recorder queue watcher",
|
name="Recorder queue watcher",
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -602,7 +602,7 @@ class Recorder(threading.Thread):
|
||||||
self.hass,
|
self.hass,
|
||||||
self._async_keep_alive,
|
self._async_keep_alive,
|
||||||
timedelta(seconds=KEEPALIVE_TIME),
|
timedelta(seconds=KEEPALIVE_TIME),
|
||||||
"Recorder keep alive",
|
name="Recorder keep alive",
|
||||||
)
|
)
|
||||||
|
|
||||||
# If the commit interval is not 0, we need to commit periodically
|
# If the commit interval is not 0, we need to commit periodically
|
||||||
|
@ -611,7 +611,7 @@ class Recorder(threading.Thread):
|
||||||
self.hass,
|
self.hass,
|
||||||
self._async_commit,
|
self._async_commit,
|
||||||
timedelta(seconds=self.commit_interval),
|
timedelta(seconds=self.commit_interval),
|
||||||
"Recorder commit",
|
name="Recorder commit",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Run nightly tasks at 4:12am
|
# Run nightly tasks at 4:12am
|
||||||
|
|
|
@ -379,7 +379,7 @@ class Scanner:
|
||||||
|
|
||||||
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.async_stop)
|
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.async_stop)
|
||||||
self._cancel_scan = async_track_time_interval(
|
self._cancel_scan = async_track_time_interval(
|
||||||
self.hass, self.async_scan, SCAN_INTERVAL, "SSDP scanner"
|
self.hass, self.async_scan, SCAN_INTERVAL, name="SSDP scanner"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Trigger the initial-scan.
|
# Trigger the initial-scan.
|
||||||
|
|
|
@ -479,7 +479,7 @@ class EntityPlatform:
|
||||||
self.hass,
|
self.hass,
|
||||||
self._update_entity_states,
|
self._update_entity_states,
|
||||||
self.scan_interval,
|
self.scan_interval,
|
||||||
f"EntityPlatform poll {self.domain}.{self.platform_name}",
|
name=f"EntityPlatform poll {self.domain}.{self.platform_name}",
|
||||||
)
|
)
|
||||||
|
|
||||||
def _entity_id_already_exists(self, entity_id: str) -> tuple[bool, bool]:
|
def _entity_id_already_exists(self, entity_id: str) -> tuple[bool, bool]:
|
||||||
|
|
|
@ -1397,6 +1397,7 @@ def async_track_time_interval(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
action: Callable[[datetime], Coroutine[Any, Any, None] | None],
|
action: Callable[[datetime], Coroutine[Any, Any, None] | None],
|
||||||
interval: timedelta,
|
interval: timedelta,
|
||||||
|
*,
|
||||||
name: str | None = None,
|
name: str | None = None,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that fires repetitively at every timedelta interval."""
|
"""Add a listener that fires repetitively at every timedelta interval."""
|
||||||
|
|
|
@ -219,7 +219,7 @@ class RestoreStateData:
|
||||||
self.hass,
|
self.hass,
|
||||||
_async_dump_states,
|
_async_dump_states,
|
||||||
STATE_DUMP_INTERVAL,
|
STATE_DUMP_INTERVAL,
|
||||||
"RestoreStateData dump states",
|
name="RestoreStateData dump states",
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_dump_states_at_stop(*_: Any) -> None:
|
async def _async_dump_states_at_stop(*_: Any) -> None:
|
||||||
|
|
|
@ -3452,7 +3452,7 @@ async def test_track_time_interval_name(hass: HomeAssistant) -> None:
|
||||||
hass,
|
hass,
|
||||||
callback(lambda x: specific_runs.append(x)),
|
callback(lambda x: specific_runs.append(x)),
|
||||||
timedelta(seconds=10),
|
timedelta(seconds=10),
|
||||||
unique_string,
|
name=unique_string,
|
||||||
)
|
)
|
||||||
scheduled = getattr(hass.loop, "_scheduled")
|
scheduled = getattr(hass.loop, "_scheduled")
|
||||||
assert any(handle for handle in scheduled if unique_string in str(handle))
|
assert any(handle for handle in scheduled if unique_string in str(handle))
|
||||||
|
|
Loading…
Add table
Reference in a new issue