Fix alarm not being fired sometimes

This commit is contained in:
Hadi Nategh 2022-03-15 18:38:25 +01:00
parent ac25c9b2b8
commit 6c75d9eb9f
2 changed files with 2 additions and 2 deletions

View File

@ -88,7 +88,7 @@ var et2_countdown = /** @class */ (function (_super) {
return 0;
var alarms = Array.isArray(this.options.alarm) ? this.options.alarm : [this.options.alarm];
for (var i = 0; i <= alarms.length; i++) {
if (alarms[i] > 0 && alarms[i] == distance / 1000 && typeof this.onAlarm == 'function') {
if (alarms[i] > 0 && alarms[i] == Math.floor(distance / 1000) && typeof this.onAlarm == 'function') {
this.onAlarm();
}
}

View File

@ -125,7 +125,7 @@ export class et2_countdown extends et2_valueWidget {
for (let i=0;i<=alarms.length;i++)
{
if (alarms[i] > 0 && alarms[i] == distance/1000 && typeof this.onAlarm == 'function')
if (alarms[i] > 0 && alarms[i] == Math.floor(distance/1000) && typeof this.onAlarm == 'function')
{
this.onAlarm();
}