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

Toothbrush integration

Scheduled Pinned Locked Moved Requests
34 Posts 5 Posters 23.9k Views 8 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.
  • D Offline
    dfuerst
    last edited by Dec 26, 2016, 7:04 PM

    Hi.
    I’m using my mirror in the bathroom. My kids and i do use Braun Oral-B electric toothbrushes, these brushes are quite popular and connectable to android or ios. We presently use the included small display’s for pressure and time control but the api should provide much more, battery level, history and so on.
    Unluckily i am a complete noob in coding.

    So if anyone is interested in developing a module for MM i would definitly support him as far as i can.
    Maybe there are others also interested in an integration.

    https://developer.oralb.com there is the api/sdk avbl

    1 Reply Last reply Reply Quote 1
    • S Offline
      Shifty
      last edited by Dec 27, 2016, 7:03 PM

      Hi,
      i want this integration, too!

      If someone needs this extention and have coding skills this will be magic!

      Tanks a lot!
      Alex

      1 Reply Last reply Reply Quote 0
      • O Offline
        onetwankyfive
        last edited by Dec 27, 2016, 8:11 PM

        This could be pretty neat

        1 Reply Last reply Reply Quote 0
        • B Offline
          bhepler Module Developer
          last edited by Dec 29, 2016, 5:27 PM

          A smart toothbrush? We truly do live in an age of wonders.

          1 Reply Last reply Reply Quote 1
          • D Offline
            dfuerst
            last edited by paviro Jan 12, 2017, 10:16 PM Jan 9, 2017, 2:31 PM

            Hi again.
            Trying to modify ianperrin’s MMM-NetworkScanner to check wether the toothbrush is connected or not!
            after pairing the brush in Raspbian it is autodetected without any delay , both availability and absensence are shown instantly.

            the plan is to detect the brush and then show a timer starting at 00:00 on the mirror, counting as long as the brush is connected. lets say: scan every 3 sec. if detect show the timer and start counting, if the brush is not detected anymore stop counting until redetection, is the brush not detected for more than 20 sec reset the timer to 00:00 and dont show it anymore

            As i mentioned, i m a noob in coding.
            i have found the command to check if an bluetoothdevice is connected : ‘hcitool con’
            but wasn’t able to use this command in the Networkscanner, i guess because of the space between ‘hcitool’ and ‘con’

            using the command manually looks as follows:(first with brush off, then with brush on)

            pi@raspberrypi:~/MagicMirror $ hcitool con
            Connections:
            pi@raspberrypi:~/MagicMirror $ hcitool con
            Connections:
            	< Unknown E0:E5:CF:FC:4D:8C handle 64 state 1 lm MASTER 
            pi@raspberrypi:~/MagicMirror $ 
            

            unsure how i can integrate this command into the MMM-Networkscanner??? and check the MAC !!! help please


            Note from admin: Please use Markdown on code snippets for easier reading!

            1 Reply Last reply Reply Quote 0
            • D Offline
              dfuerst
              last edited by Jan 9, 2017, 6:44 PM

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • D Offline
                dfuerst
                last edited by Jan 9, 2017, 6:48 PM

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • D Offline
                  dfuerst
                  last edited by paviro Jan 12, 2017, 10:16 PM Jan 12, 2017, 7:35 PM

                  ok integrated “hcitool con”, because of the very fast response,
                  had to alter the parsing of NetworkScanner.
                  i think i got the parsing, but networkscanner says NO DEVICES
                  when i “console.log(macAddresses)” , at the end of node_helper script i get during MM in console :

                  MMM-NetworkScanner received SCAN_NETWORK
                  MMM-NetworkScanner is scanning for mac addresses
                  [ ‘E0:E5:CF:FC:4D:8C’ ]                             
                  

                  shouldn’t this “macAddresses parse” be understand by NetworkScanner? What am i missing here?

                  nodehelper script is as follows:

                   scanNetwork: function() {
                          console.log(this.name + " is scanning for mac addresses");
                  
                          var self = this;
                          var arp = sudo(['hcitool', 'con']);
                          var buffer = '';
                          var errstream = '';
                  
                          arp.stdout.on('data', function (data) {
                              buffer += data;
                          });
                  
                          arp.stderr.on('data', function (data) {
                              errstream += data;
                          });
                  
                          arp.on('error', function (err) {
                              errstream += err;
                          });
                  
                          arp.on('close', function (code) {
                              if (code !== 0) {
                                  console.log(self.name + " received an error running arp-scan: " + code + " - " + errstream);
                                  return;
                              }
                              //Parse the response
                              var rows = buffer.split('\n');
                              var macAddresses = [];
                  
                              // HCI-TOOL SCAN table
                              for (var i = 1; i < rows.length; i++) {
                                  var cells = rows[i].split(' ').filter(String);
                                  if (cells[2] && macAddresses.indexOf(cells[2].toUpperCase()) === -1) {
                                      macAddresses.push(cells[2].toUpperCase());
                                  }
                              }
                  
                              self.sendSocketNotification('MAC_ADDRESSES', macAddresses);
                  	    console.log(macAddresses);
                          });
                  
                      }
                  

                  Note from admin: Please use Markdown on code snippets for easier reading!

                  S 1 Reply Last reply Jan 23, 2017, 2:23 PM Reply Quote 0
                  • S Offline
                    SvenSommer @dfuerst
                    last edited by Jan 23, 2017, 2:23 PM

                    @dfuerst Hey, I liked your approach how to get the information about a running or a stopped toothbrush.
                    So, I played some time with hcitool within the console and checked the responsive times(if the toothbrush is beeing detected as connected or not, as a turn it on or off). Unfortunately, this wasn’t very reliable nor very accurate.

                    I would suggest a better approach is to use a javascript library for bluetooth such as noble to track if the toothbrush is connected or not.
                    Unfortunately I wasn’t able to get noble running within the MagicMirror framework. I tried to install it with npm anbd several versions of node.js (6.x and 7.x) but got always an error like "Error: Module version mismatch. Expected 50, got 51." within the bluetooth-hci-socket - part of noble.

                    Starting MagicMirror: v2.1.0
                    Loading config ...
                    Loading module helpers ...
                    No helper found for module: alert.
                    No helper found for module: clock.
                    WARNING! Could not load config file. Starting with default configuration. Error found: Error: Module version mismatch. Expected 50, got 51.
                    Loading module helpers ...
                    No helper found for module: alert.
                    No helper found for module: clock.
                    App threw an error during load
                    Error: Module version mismatch. Expected 50, got 51.
                        at Error (native)
                        at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
                        at Object.Module._extensions..node (module.js:583:18)
                        at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
                        at Module.load (module.js:473:32)
                        at tryModuleLoad (module.js:432:12)
                        at Function.Module._load (module.js:424:3)
                        at Module.require (module.js:483:17)
                        at require (internal/module.js:20:19)
                        at Object. (/home/pi/MagicMirror/modules/MMM-OralB/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
                    Whoops! There was an uncaught exception...
                    Error: Module version mismatch. Expected 50, got 51.
                        at Error (native)
                        at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
                        at Object.Module._extensions..node (module.js:583:18)
                        at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
                        at Module.load (module.js:473:32)
                        at tryModuleLoad (module.js:432:12)
                        at Function.Module._load (module.js:424:3)
                        at Module.require (module.js:483:17)
                        at require (internal/module.js:20:19)
                        at Object. (/home/pi/MagicMirror/modules/MMM-OralB/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
                    
                    

                    I tried rebuilding the noble included packeages and tried it also with a clean Magicmirror installation under node.js 7.x. unfortunately nothing helped.

                    Looking for some building inspiration?
                    Check out my large, thin and metal framed mirror on robstechlog.com.

                    Modules released:
                    MMM-GoogleAnalytics
                    MMM-GrafanaChart
                    MMM-GrafanaGauges

                    D 1 Reply Last reply Jan 23, 2017, 3:57 PM Reply Quote 0
                    • D Offline
                      dfuerst @SvenSommer
                      last edited by Jan 23, 2017, 3:57 PM

                      @SvenSommer
                      hi. nice to know that someone else (with programming skills) is interested too.

                      ohh yes . ‘hcitool con’ is not perfect, first activation of the toothbrush is very accurate but as you mentioned any interruption is detected unreliably, and late.

                      your problem sounds like the “white screen” issue of mmm-button, so maybe rebuilding/downgrading your electron version might help. (see the forum for this issue)

                      as you can see in the posts above there is an API by OralB. At the end using it would give the highest quality of input/output. as you can also read between the lines i dont know enough about coding stuff, so i went for the low level approach via mmm-networkscanner and to integrate thereafter a simple stopwatch.

                      Any help is highly welcome.

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 1 / 4
                      • 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