MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Volume control

    Utilities
    2
    4
    779
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      smassy last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • S
        smassy last edited by smassy

        @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

        1 Reply Last reply Reply Quote 0
        • ?
          A Former User last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • S
            smassy last edited by

            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!

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy