• 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.

Automatically wake bluetooth speaker from sleep/suspend

Scheduled Pinned Locked Moved Troubleshooting
16 Posts 5 Posters 4.1k Views 5 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
    Stinger0815 @sdetweil
    last edited by Jul 22, 2021, 1:46 PM

    @sdetweil said in Automatically wake bluetooth speaker from sleep/suspend:

    @stinger0815 start here
    https://linuxcommand.org/lc3_wss0010.php

    but one point the filename does NOT NEED the .sh extension

    The leap from this topic to my idea is that your ‘script’ can be named the same as the program u wish to run and no one could tell it was your script instead!
    and your script can call the original program so you don’t have to recreate everything it does

    path is an important topic here. covered in the linked topic

    most of this works in windows too

    Hey thank you very much! I’ve in the meantime started to look for a hack to get it to work:

    in the node_helper of the detector module I’ve changed the function that sends the notification once the trigger command is received and added a child_process (from nodejs) there:

    
      onDetected: function (from, detected) {
        this.deactivate()
    
        let ble = require('child_process');
            ble.exec('sh bluetooth_connector.sh',
                function (error, stdout, stderr) {
                    console.log('stdout: ' + stdout);
                    console.log('stderr: ' + stderr);
                    if (error !== null) {
                         console.log('exec error: ' + error);
                    }
                });
    
        this.sendSocketNotification("DETECTED", { from: from, key: detected } )
      },
    
    

    The script that is called by exec “bluetooth_connector” only contains:

    #!/bin/bash
    
    bluetoothctl \
    connect <<BLE ADDRESS>>
    exit
    

    pretty hacky but does the job for now. I’ll now try to figure out whether this is actually decoupled enough so that the exec does not block the rest of the application. As I can tell from the logs it looks like the script is decoupled and runs in the background - what is good.

    So as this is running now I’ll look into the solution you gave.

    B 1 Reply Last reply Jul 22, 2021, 3:47 PM Reply Quote 0
    • B Offline
      bugsounet Banned @Stinger0815
      last edited by Jul 22, 2021, 3:47 PM

      (if you think that is the better solution… I will engage you for coding :D)

      S 1 Reply Last reply Jul 22, 2021, 4:15 PM Reply Quote 0
      • S Offline
        Stinger0815 @bugsounet
        last edited by Jul 22, 2021, 4:15 PM

        @bugsounet said in Automatically wake bluetooth speaker from sleep/suspend:

        (if you think that is the better solution… I will engage you for coding :D)

        :face_with_hand_over_mouth:

        It’s certainly not a perfect solution - I have to add that every time there is an update in the detector helper - ohh, surprise, there is an update in the detector module :D

        B 1 Reply Last reply Jul 22, 2021, 5:36 PM Reply Quote 0
        • B Offline
          bugsounet Banned @Stinger0815
          last edited by Jul 22, 2021, 5:36 PM

          @stinger0815

          humm…
          i’m so kind today … so try v3.0.4 of GA with this recipe:

          var recipe = {
            commands: {
              "Bluetooth": {
                shellExec: {
                  exec: (params) => {
                    if (params.notification == "GA_ACTIVATE") return "bluetooth_connector.sh"
                    else return null
                  }
                }
              }
            },
            plugins: {
              onNotificationReceived: "Bluetooth"
            },
          }
          
          exports.recipe = recipe
          

          Note maybe you have to add path in the return value example /home/pi/bla/bla/bluetooth_connector.sh

          S 1 Reply Last reply Jul 22, 2021, 7:39 PM Reply Quote 0
          • S Offline
            Stinger0815 @bugsounet
            last edited by Jul 22, 2021, 7:39 PM

            @bugsounet said in Automatically wake bluetooth speaker from sleep/suspend:

            @stinger0815

            humm…
            i’m so kind today … so try v3.0.4 of GA with this recipe:

            var recipe = {
              commands: {
            [...]
            
            Note maybe you have to add path in the return value example `/home/pi/bla/bla/bluetooth_connector.sh`
            

            That’s pretty sweet and works fine :) Thank you very much!

            B 1 Reply Last reply Jul 22, 2021, 7:57 PM Reply Quote 0
            • B Offline
              bugsounet Banned @Stinger0815
              last edited by Jul 22, 2021, 7:57 PM

              that i says: i’m so kind today

              because i offer no help there, so today you have a lot of chance :)

              1 Reply Last reply Reply Quote 0
              • B Offline
                bert269 @Stinger0815
                last edited by sdetweil Jul 25, 2021, 11:36 AM Jul 25, 2021, 7:24 AM

                @stinger0815 : I am so sorry to “hijack” your thread. But do you perhaps have the correct steps to follow to install and get GA to work on the rpi? I have tried numerous threads, but all are out-dated and different from Google’s current developer screens - So I get to a spot where things are no longer working.
                Google does not really help either, as I have raised questions, that gets not answered.

                Thank you and I apologize again.

                D 1 Reply Last reply Jul 25, 2021, 7:54 AM Reply Quote 0
                • D Offline
                  DJBOOB66 @bert269
                  last edited by Jul 25, 2021, 7:54 AM

                  @bert269
                  [http://wiki.bugsounet.fr/en/MMM-GoogleAssistant](link url)

                  1 Reply Last reply Reply Quote 2
                  • 1
                  • 2
                  • 2 / 2
                  2 / 2
                  • First post
                    13/16
                    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