fewieden / MMM-AlarmClock

Alarm Clock Module for MagicMirror²
MIT License
47 stars 18 forks source link

Per-alarm timeout not working #49

Open thisisjjd opened 2 months ago

thisisjjd commented 2 months ago

Platform (Hardware/OS): Raspberry Pi 3 Model B Rev 1.2, Raspbian GNU/Linux 12 (bookworm)

Node version: 20.15.0

MagicMirror version: v2.28.0

Module version: 2.0.2

Description of the issue:

From my testing, the per-alarm "timer" value is ignored.

I have tried both with and without an overall "timer" value being set. The overall timer value is used whether or not a per-alarm timer is set. If there is no overall timer value set, then the per-alarm value of "timer" seems to be ignored and the default per-alarm timer of 1 minute is used.

Here is a summary of my testing:

overall              per-alarm                    result
-------------------------------------------
set                  not set                         overall value is used
set                  set                             overall value is used
not set              set                             default overall 1-minute value is used
not set              not set                         default overall 1-minute value is used

Looking at the code, if I'm reading it right, it appears the per-alarm timer is ignored if "touch" is enabled:

            let timer = this.config.timer;
            // If the alarm has specific timer and if MM is not touch, we use the alarm timer.
            if (typeof this.next.timer !== 'undefined' && !this.config.touch) {
                timer = this.next.timer;
            }
            if (!this.config.touch) {
                alert.timer = timer;
            }

Is there a way to set per-alarm timeouts even if you have "touch" enabled?

Here is what my config looks like:

    {
        disabled: false,
        module: 'MMM-AlarmClock',
        position: 'top_center',
        config: {
        alarms: [
            { 
            time: "06:00",
            days: [1,2,3,4,5], 
            title: "Wake Up for work",
            message: "You have to go to work today",
            sound: "https://fm909.wbur.org/wbur_www",
            timer: 60 * 60 * 1000 
            },
            { 
            time: "11:28", 
            days: [0,1,2,3,4,5,6],
            title: "Test alarm",
            message: "Will it blend?",
            sound: "https://fm909.wbur.org/wbur_www",
            timer: 30 * 1000 
            },
        ],
        // overall timer setting commented out
        // timer: 60 * 60 * 1000, 
        format: "dd H:mm",
        touch: true,
        popup: true,
        fade: true,
        fadeTimer: 30000,
        fadeStep: 0.0333,
        }
    },

In this example (with the overall "timer setting commented out), "Test alarm" goes off at 11:28, but doesn't stop after 30 seconds. Instead, it continues until the (default) 60 seconds and then stops.