Handle case where timer device id exists but is not registered (delayed command) (#118410)

Handle case where device id exists but is not registered
This commit is contained in:
Michael Hansen 2024-05-29 14:18:46 -05:00 committed by GitHub
parent a0443ac328
commit 43ceb1c6c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -229,7 +229,9 @@ class TimerManager:
if (not conversation_command) and (device_id is None):
raise ValueError("Conversation command must be set if no device id")
if (device_id is not None) and (not self.is_timer_device(device_id)):
if (not conversation_command) and (
(device_id is None) or (not self.is_timer_device(device_id))
):
raise TimersNotSupportedError(device_id)
total_seconds = 0
@ -276,7 +278,7 @@ class TimerManager:
name=f"Timer {timer_id}",
)
if timer.device_id is not None:
if timer.device_id in self.handlers:
self.handlers[timer.device_id](TimerEventType.STARTED, timer)
_LOGGER.debug(
"Timer started: id=%s, name=%s, hours=%s, minutes=%s, seconds=%s, device_id=%s",