MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

Volume control



  • Re: MMM-Volume

    @Sean

    Hello, just got the volume part to work but when I tested it I got a strange behavior.

    first my code:

    This is the content of my recipe file in MMM-AssistantMK 2
    (https://github.com/eouia/MMM-AssistantMk2/)

    var recipe = {
        transcriptionHook: {
            "volume_down": {
                pattern: "Baisse le volume", 
                command: "volume_down"
            },
            "volume_up": {
                pattern: "Monte le volume",
                command: "volume_up"
            },
            "volume_set": {
                pattern: "Volume ([0-9]{1,2}[0]?|100) %",
                command: "volume_set"
            },
    
        },
        command: {
            "volume_down": {
                notificationExec: {
                    notification: "VOLUME_DOWN",
                }
            },
            "volume_up": {
                notificationExec: {
                    notification: "VOLUME_UP",
                }
            },
            "volume_set": {
                notificationExec: {
                    notification: "VOLUME_SET",
                    payload: (params, key) => {
                        return params[1];
                    }
                }
            },
        },
    }
    exports.recipe = recipe
    

    When I call to Up/down volume it work fine (with a 10 updownscale) It break when I call VOLUME_SET to set it to a specific level (let say 30) and then if I call VOLUME_UP it goes straight to 100 but If I call VOLUME_DOWN first it will work perfectly and go to 20.

    I missed something?

    Thank you!



  • @Sean

    Just to let you know.

    the ‘-M’ did not fixed the volume problem. I found out ,using the console, that the variable, for an unknown reason, when I use ‘VOLUME_SET’ followed by ‘VOLUME_UP’ it append the current volume number and the updownscale instead of doing the addition.

    using volume_set 50 and updownscale 10

    Console:

    Block
          curUpDownScale: 10
          vol: "5010"
    

    But when I use ‘VOLUME_SET’ followed by ‘VOLUME_DOWN’ it work with no issue. Also in that order I can use ‘VOLUME_UP’ after…

    I also realized that the vol number is not between double quote

    Block
          curUpDownScale: 10
          vol: 40
    

    Still looking to find where it breaks


  • Module Developer

    Thanks for your report.
    Value of volume is number(integer, from 0 to 100), so when you use VOLUME_UP or VOLUME_DOWN, this module will add/subtract updownScale to/from currentVolume. But it will work when those values are number. if you’ve set string(text) as the value, (like “50” and “10”) It will append one string to other string like “5010”.
    So, use the volume value as number(integer), not string(with quotation mark).
    Someday, I’ll modify source to convert string to number, maybe on next update.



  • Last time I bug you with that I promise.😇

    I fixed it that way

          case this.config.notifications.VOLUME_DOWN:
            var vol = parseInt(this.currentVolume) - curUpDownScale
            if (vol < 0) vol = 0
            this.sendSocketNotification(this.config.notifications.VOLUME_SET, vol)
            break
          case this.config.notifications.VOLUME_UP:
            var vol = parseInt(this.currentVolume) + curUpDownScale
            if (vol > 100) vol = 100
            this.sendSocketNotification(this.config.notifications.VOLUME_SET, vol)
            break
    

    By adding the parseInt to make sure that it’s an integer.

    All working fine now!!

    Thank again, really like your module!


Log in to reply