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

MMM-GoogleAssistant and LED Lights



  • I am using the module made by bugsounet, the MMM-GoogleAssistant and the MMM-Assistant2Display. I am trying to setup some LED lights behind the mirror’s frame to come on when the hotword is spoken/when the assistant is talking. Much like how the Amazon Echo does. I have the LED lights installed connected to a N-Channel MOSFET. My trouble is trying to figure out how to activate a GPIO pin at the time when the hotword is spoken and when the assistant is talking. I only have a PIR sensor plugged in on GPIO14 or pin 8 so almost all pins are available. I have been trying to run searches for help on this but I have been unsuccessful (probably using the wrong keywords 😂 😂 ). Any help would be greatly appreciated. Thanks!



  • @Pyroson u will need a module, with a node_helper to talk to the gpio pins, as u can’t do that from the modulename.js as it runs in the browser.

    there might be a generic module to twiddle the LEDs.



  • @Pyroson here is a module that turns off/on LEDs on gpio

    https://github.com/idoodler/MMM-RPI-LED

    you could extend that to twiddle the lights like u need



  • curious to this aswell as i have the ReSpeaker 4 mic array with 12 leds and i was trying to do the same… as far as i know theres 4 stage: wake up, listen, think and speak. i have sample python scripts for each stage with a corresponding light patternand im still looking to see if i can figure it out where to call them from but no joy yet! 😕

    for me when looking through @Bugsounet code, it all appears on one line (no line breaks) and is pretty hard to try and read… is this on purpose and the same for all?

    thanks



  • @banbutcher python will have to be called from a node_helper as well, as u can’t exec code from a browser.

    there are all kinds of examples of this.

    his code is minified, makes it faster to execute, and harder to take.


  • Module Developer

    my code is protected, you can’t modify it.
    If you modify it, MM will close (self protected of GA/A2D)

    I will explain to you tomorrow how you can do
    If you have some python code, you can do it with GA (GA have some trigger on every events and you can use it)



  • @Bugsounet @sdetweil

    Thanks guys


  • Module Developer

    @banbutcher @Pyroson

    I have write a special recipe for you, with the latested version of MMM-GoogleAssistant 🙂

    the recipe name is with-status.js (locating: with the latest version of GA in recipes directory)

    • How it’s works ?
      GA will send the status (stand-by, listen, …) to your wanted file
    
    /**  with-status.js **/
    /**  send the status of assistant to a python script **/
    /** For LED Strip for example **/
    /**     @bugsounet       **/
    
    var recipe = {
      commands: {
        "Status": {
          shellExec: {
            exec: (param) => {
                return "python /home/pi/myscript.py " + param.status.actual
            }
          }
        }
      },
      plugins: {
        onStatus: "Status"
      },
    }
    
    exports.recipe = recipe
    

    I have defined in the with-status.js sample
    to run this command : python /home/pi/myscript.py Status_of_GA

    • Status_of_GA can be :
      • listen
      • standby
      • confirmation
      • reply
      • error
      • hook
    • You can change the name and the path of the script (I don’t force it) and can be and bash script or other
    • How load this recipe ?

    in GA configuration, you have an recipe field

    just add it 🙂

    samples :

    • recipes: [ "with-status.js" ],

    • recipes: [ "with-status.js", "with-MMM-TelegramBot.js" ], for some other recipe needed

    @bugsounet



  • cool, thanks a lot for this, im looking forward to trying some stuff out! 🙂



  • @Bugsounet
    Hi guys, i’m new to python and i’m not sure how I would create a script that would turn on different GPIO pins depending on the GA staus. If someone could point me in the right direction that would be awesome!


Log in to reply