mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Fixes issue with multiple alerts (#23945)
* Fixes issue with multiple alerts * Adds missing new line * Remove whitespace
This commit is contained in:
parent
91ba35c68e
commit
57bd4185d4
@ -1,7 +1,7 @@
|
|||||||
"""Support for repeating alerts when conditions are met."""
|
"""Support for repeating alerts when conditions are met."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE, ATTR_ENTITY_ID)
|
SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE, ATTR_ENTITY_ID)
|
||||||
from homeassistant.helpers import service, event
|
from homeassistant.helpers import service, event
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
|
from homeassistant.util.dt import now
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -222,7 +223,7 @@ class Alert(ToggleEntity):
|
|||||||
async def _schedule_notify(self):
|
async def _schedule_notify(self):
|
||||||
"""Schedule a notification."""
|
"""Schedule a notification."""
|
||||||
delay = self._delay[self._next_delay]
|
delay = self._delay[self._next_delay]
|
||||||
next_msg = datetime.now() + delay
|
next_msg = now() + delay
|
||||||
self._cancel = \
|
self._cancel = \
|
||||||
event.async_track_point_in_time(self.hass, self._notify, next_msg)
|
event.async_track_point_in_time(self.hass, self._notify, next_msg)
|
||||||
self._next_delay = min(self._next_delay + 1, len(self._delay) - 1)
|
self._next_delay = min(self._next_delay + 1, len(self._delay) - 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user