mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Simplify mqtt discovery cooldown calculation (#118095)
This commit is contained in:
parent
5c60a5ae59
commit
4da125e27b
@ -1257,9 +1257,7 @@ class MQTT:
|
|||||||
|
|
||||||
last_discovery = self._mqtt_data.last_discovery
|
last_discovery = self._mqtt_data.last_discovery
|
||||||
last_subscribe = now if self._pending_subscriptions else self._last_subscribe
|
last_subscribe = now if self._pending_subscriptions else self._last_subscribe
|
||||||
wait_until = max(
|
wait_until = max(last_discovery, last_subscribe) + DISCOVERY_COOLDOWN
|
||||||
last_discovery + DISCOVERY_COOLDOWN, last_subscribe + DISCOVERY_COOLDOWN
|
|
||||||
)
|
|
||||||
while now < wait_until:
|
while now < wait_until:
|
||||||
await asyncio.sleep(wait_until - now)
|
await asyncio.sleep(wait_until - now)
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
@ -1267,9 +1265,7 @@ class MQTT:
|
|||||||
last_subscribe = (
|
last_subscribe = (
|
||||||
now if self._pending_subscriptions else self._last_subscribe
|
now if self._pending_subscriptions else self._last_subscribe
|
||||||
)
|
)
|
||||||
wait_until = max(
|
wait_until = max(last_discovery, last_subscribe) + DISCOVERY_COOLDOWN
|
||||||
last_discovery + DISCOVERY_COOLDOWN, last_subscribe + DISCOVERY_COOLDOWN
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _matcher_for_topic(subscription: str) -> Callable[[str], bool]:
|
def _matcher_for_topic(subscription: str) -> Callable[[str], bool]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user