Karotz can connect to the internet and you can deploy applications on it. It’s a tiny multitalent, speaks, blinks, turns his ears, takes photos and plays musik. The really cool stuff about all this, is that you can also access it via a REST-api.
I was a little disturbed by the bad documentation of the api, but since Karotz has had a pretty shaken history, I was willing to see over it. Nevertheless I had a really hard time figuring out how to use the API, especially the interactiveMode sessions, which are crucial for interacting with Karotz. That’s why I wanted to give you a short HOW-TO wrapup on it.
First of all you need to have a Karotz up and running, like it’s described in the handbook. Register yourself at karotz.com and click on the lab button at the bottom of the page. Once you registered yourself for all the developer stuff, you need to register a new application for yourself in order to get access to the credentials needed to talk to Karotz.
In order to get your own application, you need to create a descriptor.xml and package it as a zip-file and then load it up to the appstore and then deploy it to your bunny. Here is an example, which exposes the install-id of your application, which you need to accesss your Karotz:
<descriptor> <version>0.0.1</version> <accesses> <access>tts</access> <access>ears</access> <access>led</access> <access>multimedia</access> </accesses> <deployment>external</deployment> <parameters> <parameter key="showInstallUuid" value="true"/> </parameters> </descriptor>
Have a look at this Christops Blog if you don’t get it working for yourself.
Using the Gem
There are already some code-examples on the developer-pages on how to get an interactive_id for your Karotz and some code has been released for Ruby as ruby-karotz here and here none of them exposing a nice API or describing the process of how to get all the peaces of the puzzle together. That’s why I am currently writing this…
So here is an example of how to interact with the karotz gem:
Karotz::Configuration.configure do |config| config.install_id = ENV['KAROTZ_INSTALL_ID'] config.api_key = ENV['KAROTZ_API_KEY'] config.secret = ENV['KAROTZ_SECRET'] end Karotz::Client.session do |karotz| karotz.ears karotz.led karotz.say karotz.play end
This will rotate Karotz ears, blink the LED, say ‘test’ and let it play the A-TEAM theme!