• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Volume control

Scheduled Pinned Locked Moved Utilities
4 Posts 2 Posters 1.1k Views 2 Watching
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 Offline
    smassy
    last edited by Sep 6, 2019, 1:16 AM

    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 Offline
      smassy
      last edited by smassy Sep 17, 2019, 4:04 AM Sep 17, 2019, 4:03 AM

      @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
      • ? Offline
        A Former User
        last edited by Sep 17, 2019, 8:45 AM

        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 Offline
          smassy
          last edited by Sep 18, 2019, 1:19 AM

          Last time I bug you with that I promise.:smiling_face_with_halo:

          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 Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy