Automating Ooma’s Do Not Disturb Feature

Ooma VOIP service provides a Do Not Disturb feature to it’s Premiere Subscribers. Unfortunately, the usefulness of this service is greatly hampered by an inability to schedule when Do Not Disturb is enabled. Instead, you have to manually dial a special code to enable (*78) and disable (*79) Do Not Disturb. It gets quite tiresome to remember to enable/disable this feature, which for me made it next to useless.

But with a Raspberry Pi (or really any computer) and a 56K USB modem, automating Do Not Disturb for Ooma is actually quite straightforward! Which is a lifesaver for me, my wife, and my 1 year old son that doesn’t respond well to telemarketers calling at 8 or 9 o’clock at night.

Here’s what you need:

  1. Raspberry Pi or other Linux computer – I chose the Pi because I had one sitting around, and it’s perfect for leaving on all the time since it’s very friendly from an energy consumption perspective.
  2. 56K USB Modem – The first modem I ordered did NOT have available Linux drivers, so be sure to get one that does, or better yet, order the one I used, a USRobotics USR5637.
  3. Small Phone Line and Splitter – Click here for the splitter I used. Any old RJ11 US telephone line will work for connecting the modem.

Here’s how things get wired up from the phone/modem perspective:

[ooma] spliter

Once wired, boot your Raspberry Pi and plug in your new modem. Open up a Terminal on the Rpi and execute the following:

dmesg

In addition to other previous output, you should get something similar to the following near the bottom:

[66465.356086] usb 1-1.4: USB disconnect, device number 5
[66479.668610] usb 1-1.4: new high-speed USB device number 20 using dwc_otg
[66479.769773] usb 1-1.4: New USB device found, idVendor=0baf, idProduct=0303
[66479.769800] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=10
[66479.769818] usb 1-1.4: Product: USB Modem
[66479.769834] usb 1-1.4: Manufacturer: U.S.Robotics
[66479.769850] usb 1-1.4: SerialNumber: 0000002
[66479.801209] cdc_acm 1-1.4:2.0: ttyACM0: USB ACM device
[66479.802014] usbcore: registered new interface driver cdc_acm
[66479.802032] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

We’re looking for where the new modem was mounted, specifically this line (mine was mounted at /dev/ttyACM0:

[66479.801209] cdc_acm 1-1.4:2.0: ttyACM0: USB ACM device

Nice! The modem is up and working. Now we need a script to talk to it. Well, a couple scripts, actually. We’ll be using a minicom script to send the *78/*79 numbers to Ooma.

Using your favorite editor (mine is vim), create a new file called dnd-off.mini, and paste in the following:

send ATD*79
sleep 3
! killall -15 minicom

Create another file called dnd-on.mini, and fill it with:

send ATD*78
sleep 3
! killall -15 minicom

You can immediately test these two scripts. Make sure they are both executable (e.g., chmod +x dnd-on.mini) and test them out (minicom -S dnd-on.mini -D /dev/ttyACM0). Make sure you fill in the correct path to your script, and use the correct device. If everything is working correctly, you should see the light on top of your Ooma box turn purple, indicating that Do Not Disturb is active. You can run the -off version of the script to disable it, and your Ooma light should turn blue. See how easy that was??

Now for the automation part. I created a “parent” script that, when given the appropriate command line parameter, will execute either the -on or -off version of the script. Open up your text editor again to create a ‘dnd’ shell script:

#!/bin/bash

if [ $1 == "enable" ]; then
     minicom -S /home/pi/scripts/dnd-on.mini -D /dev/ttyACM0
elif [ $1 == "disable" ]; then
     minicom -S /home/pi/scripts/dnd-off.mini -D /dev/ttyACM0
fi

You can test this script by itself. Make it executable and then run it with ./dnd enable or ./dnd disable. You should see minicom fire up, dial the appropriate number, and then kill itself.

Last but not least, the scheduling part! My son goes to bed at 7pm and gets up at 6am, so that is my “window of silence”. All you have to do is edit the crontab on the Pi to execute the appropriate enable/disable command at the appropriate time every day. Here’s what my crontab looks like for my window. You can do the same for yours by editing crontab with crontab -e. If you want a cool way to easily decipher cron listings, check out Corntab. NOTE – minicom and cron don’t play well together, because minicom expects access to a terminal. To get by this, we can launch minicom in a GNU screen session in the background. Here’s how you do that in your crontab:

0 19 * * * screen -d -m /home/pi/scripts/dnd enable
0 6 * * * screen -d -m /home/pi/scripts/dnd disable

Done! With less than 30 minutes worth of work we’ve shimmed Ooma’s Do Not Disturb service to be much MUCH more usable. Be sure to leave a comment below if this helped you out!

Spread the word. Share this post!

8 Comments

  1. EV

    Reply

    Thanks, that’s a nice solution except A.) who has a modem anymore, B.) I take issue with spending money I fixing a bug/feature that Ooma should fix and C.) There’s no option to remotely control this. The last one is important b/c many folks buy these for a senior parent and enabling DND is too easy.

    • castleseven

      Reply

      A – Rarely anyone has a USB modem anymore, but to communicate to Ooma from a single board computer, you’re gonna need one.
      B – If you want the feature bad enough, you’ll spend the cash on a modem and Rpi, because otherwise you’ll just do without the missing feature.
      C – There are plenty of options for remote control, I just don’t need them. Port forward your RPi, write up a little HTML and PHP, and you can turn it on and off yourself from anywhere in the world. But to be quite honest, this has been a completely set-and-forget thing for me, I haven’t visited the RPi since I made the original post, and it’s still working great. If you end up taking this further, I’d love to see whatever remotely accessible solution you come up with, I just didn’t need it for mine.

  2. Kevin Bridgewater

    Reply

    Some time later …
    Lightning got my modem, so looking for a better way to do this.

    Turn out they have made control of DND available in the local web interface to the telco device.
    (try http:\\172.27.35.1\system.lp)
    So,
    Install NodeJS:
    On RPI you need to update to a version greater than 4, so:
    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash –
    sudo apt install nodejs
    Now install Zombie:
    sudo npm install zombie -g

    enable.js =
    var Browser = require(“zombie”);
    var myArgs = process.argv.slice(2);
    var url = “http://” + myArgs[0] + “:” + myArgs[1] + “@” + myArgs[2] + “/system.lp”
    var browser = new Browser();

    browser.visit(url, function() {
    var ids = browser.queryAll(‘a’);
    for (var id of ids) {
    if (browser.text(id) == “Enable Do Not Disturb”) {
    browser.pressButton(id);
    }
    }
    });

    disable.js =

    var Browser = require(“zombie”);
    var myArgs = process.argv.slice(2);
    var url = “http://” + myArgs[0] + “:” + myArgs[1] + “@” + myArgs[2] + “/system.lp”
    var browser = new Browser();

    browser.visit(url, function() {
    var ids = browser.queryAll(‘a’);
    for (var id of ids) {
    if (browser.text(id) == “Disable Do Not Disturb”) {
    browser.pressButton(id);
    }
    }
    });

    Then to disable:
    node disable.js admin admin 172.27.35.1

    • castleseven

      Reply

      Wow, awesome work Kevin! Thanks for the tips, awesome that they’ve made it available locally without having to pickup the handset. If my modem eventually bites the dust I’m definitely switching to this. Thanks for the code too!

    • street9009

      Reply

      Has the code to do this changed? I’m getting an error (SyntaxError: Unexpected identifier) on the for (var id of ids) line and it’s pointing at ‘of’. It’s like the queryAll statement above it returned nothing.

      • castleseven

        Reply

        Sorry for the super late reply street9009, notifications weren’t coming through. As far as I can tell queryAll is still part of the API for zombie. If you’re copying code straight from the site, it may be an issue with the single-quotes surrounding the ‘a’ identifier, that’d be my first blind guess. You could also check what is in the ids array –

        const elements = this.browser.queryAll(selector);
        assert(elements.length, `Expected selector “${selector}” to return one or more elements`);

        I’m not a JS guy so these are just best guesses.

Leave Comment

Your email address will not be published. Required fields are marked *