diff --git a/lib/speech2device.js b/lib/speech2device.js index 6ea43a1..a8b40d5 100644 --- a/lib/speech2device.js +++ b/lib/speech2device.js @@ -280,7 +280,10 @@ class Speech2Device { let count = 0; let intervalHandler = setInterval(async () => { count++; - if (count > 20) { + // We are checking every 500 ms, expected length of playback is defined in variable duration in seconds + // Thus, we have to count to duration*2 to be able to wait long enough for the expected playback duration. + // We add two additional seconds, to cover delays before the playback starts. + if (count > (duration+2)*2) { clearInterval(intervalHandler); intervalHandler = null; this.adapter.log.error(`Error while checking if ${chromecastAnnouncementDev} finished playing announcement: ${announcementJSON}: TIMEOUT`);