Limit waze_travel_time to 1 call every 0.5s (#100191)

This commit is contained in:
Kevin Stillhammer 2023-09-13 13:29:20 +02:00 committed by GitHub
parent 1f1411b6a5
commit 958b923783
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
"""Support for Waze travel time sensor."""
from __future__ import annotations
import asyncio
from datetime import timedelta
import logging
from typing import Any
@ -48,6 +49,10 @@ _LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(minutes=5)
PARALLEL_UPDATES = 1
MS_BETWEEN_API_CALLS = 0.5
async def async_setup_entry(
hass: HomeAssistant,
@ -144,6 +149,7 @@ class WazeTravelTime(SensorEntity):
self._waze_data.origin = find_coordinates(self.hass, self._origin)
self._waze_data.destination = find_coordinates(self.hass, self._destination)
await self._waze_data.async_update()
await asyncio.sleep(MS_BETWEEN_API_CALLS)
class WazeTravelTimeData: