in Internet of Things, Prolog

Supercharging the Nabaztag

The Nabaztag is a WiFi enabled ambient device shaped like a bunny. It has moveable ears, a speaker, several LEDs, and a button on its head. The second generation (the one I have) also has a microphone, an RFID sensor, and supports MP3 audio streams.

These Nabaztag bunnies rely on a server to function. Originally the company that produced these things provided for one but after they went bankrupt in 2009, thousands of these devices were rendered useless.

Luckily, various alternative servers were developed. These servers often make use of plugins to give the connected bunnies certain abilities. Extending your bunny with new capabilities requires some programming skills if there is no existing plugin that already does what you want.

I developed my own Nabaztag server in Prolog that you can download from this repository. Instead of making use of plugins to extend a Nabaztag’s capabilities, my server simply forwards all events to an IFTTT webhook. The server also exposes an API to do things like play audio, flash LEDs, move the ears, do TTS, etc. This API can be called from the IFTTT platform.

In case you don’t know, IFTTT (which stands for IF This Then That) is a platform that allows you to connect certain actions to certain triggers. You can for instance setup a ‘recipe’ to turn on your Philips Hue lights (the action) when you phone connects to your home WiFi network (the trigger). Another example would be a recipe that sends you a Telegram message (the action) when the weather forecast predicts it’s going to rain (the trigger). By making use of IFTTT webhooks we can integrate triggers and actions of the Nabaztag into our recipes.

I’ll describe a few recipes that I setup to give you an idea of the possibilities. In the recipes below I assume the Nabaztag server is running and reachable at IP address 123.123.123.123.

One recipe makes the Nabaztag greet me when I get home. For this you need to have the IFTTT app installed on your phone.

  • Trigger: Android device, Connects to a specific WiFi Network
    • Network name: SSID_of_your_home_WiFi
  • Action: Webhooks, make a web request
    • URL: http://123.123.123.123/vl/api/tts.jsp
    • Method: POST
    • Content Type: application/x-www-form-urlencoded
    • Body: sn=0013d3123456&text=Welcome%20home

Replace the parts in italic (the network name, IP address in the URL, and bunny’s serial number in the body) with your specifics.

I also wanted the bunny to strike the hour like a cuckoo clock. For this I added 24 recipes, one for each hour. This is the one for 5PM.

  • Trigger: Date & Time, Every day at
    • Time: 05 PM, 00 minutes
  • Action: Webhooks, make a web request
    • URL: http://123.123.123.123/vl/api/play.jsp
    • Method: POST
    • Content Type: application/x-www-form-urlencoded
    • Body: sn=0013d3123456&url=http://123.123.123.123/vl/sounds/cuckoo5.mp3

Again, change the options in italics to your specifics.

The Nabaztag has various built-in ambient LED patterns that it can show when not doing anything else. There are built-in patterns that show the state of the weather, the market, traffic, messages, and air quality. We can set these ambient patterns on receiving certain triggers. For instance, we can set the ambient weather pattern to rain when the forecast for a certain location is rain:

  • Trigger: Weather Underground, Current condition changes to
    • Current Condition: Rain
    • Location: Your location
  • Action: Webhooks, make a web request
    • URL: http://123.123.123.123/vl/api/ambient.jsp?sn=0013d3123456&weather=rain
    • Method: POST
    • Content Type: text/plain
    • Body:

Add similar recipes for other weather conditions. Similarly one can make the bunny show ambient patterns that indicate what’s going on in the financial market if you’re keen on keeping track of that.

One can also record a message on the Nabaztag by keeping the button on its head pressed. After the bunny beeps, you can speak into its microphone. On release, the recorded message is sent to the server. The server saves the message to a WAV file and sends the location of that file to the IFTTT platform where it can be caught using a webhook. The following recipe shows how this can be used to send an email every time a message is recorded.

  • Trigger: Webhooks, Receive a web request
    • 0013d3123456_record_click
  • Action: Email, Send me an email
    • Subject: New message from your Nabaztag
    • Body: Dear master,<br><br>On {{OccurredAt}} a message was recorded on your Nabaztag. Click <a href=”{{Value1}}”>here to download</a>.<br><br>Sincerely,<br><br>Your favourite bunny

These examples should be enough to get you started. Read the README.md file in the repository for details on how to configure the server and how to use the API. Take note that before running the server you’ll need to enter the Nabaztag’s serial number, your IFTTT Webhook key, and server details into the config.pl file.

Share your recipe ideas in the comments below!

Write a Comment

Comment

12 Comments

  1. Hello Aswin,
    I brought my two rabbits back to life thanks to the instructions from Nabaztaglives.com. Unfortunately, I only found your instructions afterwards. But you’re going exactly in the direction I want to go. But I would very much like to integrate the rabbit into my smarthome via Homebridge. So a plugin for homebridge that communicates with the rabbit. The rabbit “sniff” the RFID chips again! Since then I have been driven by the thought that it should definitely be that the ZStamps and Nanos (RFID chips) should somehow get into the HomeKit as a contact sensor via the HomeBridge. Could you do something like that? I am happy to pay you for your effort.
    best regards
    Udo

    • Hi Udo,

      I have no experience with Homebridge, but I did see there’s a webhooks plugin (https://www.npmjs.com/package/homebridge-http-webhooks). What you could do is install this plugin, open up a port on your router and trigger this webhook from the ifttt platform. Schematically it would look like this:

      Nabaztag sniffs RFID -> Send RFID code to Nabaztag server (the one I wrote) -> triggers IFTTT -> Triggers your homebridge webhook

      I hope this helps

      • Hallo Aswin,

        danke für deine Antwort. Das ich mit deiner Plattform genau das erreichen kann, hab ich verstanden. Deine Lösung ist auch der Hammer! Und du kannst dir sicher sein, dass ich gerade dabei bin, zu versuchen deinen Server zu installieren. Die Sensoren direkt im HomeKit abzubilden, wäre nur noch die Krönung gewesen:) Sobald ich es geschafft habe, alles an laufen zu bringen, gebe ich gern noch mal Bescheid.
        Beste Grüße
        Udo

      • Hello Aswin,

        Thank you for your answer. I understand that I can achieve exactly that with your platform. Your solution is also awesome! And you can be sure that I am currently trying to install your server. Imaging the sensors directly in the HomeKit would have been the icing on the cake 🙂 As soon as I have managed to get everything going, I will be happy to let you know again.
        Best regards
        Udo

  2. Hi there,

    I have now installed SWI-Prolog on the Mac following these instructions: https://www.swi-prolog.org/build/macos.html

    I chose the variant with hombrew.

    I downloaded the “nabaztag-master” files.
    I added config.pl with the mac address of a rabbit and the webhook.

    Where do the files have to be copied to?

    LG

    Udo

    • You can place them anywhere you like. To run the server you can execute from the command line

      ./nabaztagd.pl –fork=true –ip=localhost –port=8080 –workers=4

      Adjust the port number if you didn’t enter 8080 in the config.pl file and would like to use another port number. You can use 80, but then you have to execute using sudo. Make sure the bunny also connects to the right port.

      See if a bunny boots and downloads the bootcode. The nabaztag server keeps a log file called httpd.log that you can check to see if the bunny connects.

      If you want to check if the server is still running you can type:

      ps aux | grep nabaztag

      • correct for 2 rabbits?

        % config.pl
        % Aswin van Woudenberg

        public_host(‘<>’). <-ip macOS
        public_port(<>). <-freely chosen port
        server_port(<>).

        ping(‘<>’,10).
        ambient(‘<<xx:xx:xx:xx:xx:xx',[],0,0,0).
        ifttt('<>’,'<>’).
        packets(‘<>’,[]).

        ping(‘<>’,10).
        ambient(‘<>’,[],0,0,0).
        ifttt(‘<>’,'<>’).
        packets(‘<>’,[]).

        • % config.pl
          % Aswin van Woudenberg

          public_host(‘<>’).
          public_port(<>).
          server_port(<>).

          ping(‘<>’,10).
          ambient(‘<>’,[],0,0,0).
          ifttt(‘<>’,'<>’).
          packets(‘<>’,[]).

          ping(‘<>’,10).
          ambient(‘<>’,[],0,0,0).
          ifttt(‘<>’,'<>’).
          packets(‘<>’,[]).