Making my first plugin : ThinkingCleaner for Roomba

Posted on
Mon Jan 25, 2016 1:01 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Making my first plugin : ThinkingCleaner for Roomba

Since it doesn't look like anyone else has made or shared a plugin for the thinkingcleaner wifi add on for roomba, I am going to try for my self.
This will then be my first plugin, so I hope someone can point me in the right direction.

The thinkingcleaner has a well defined (in my opinion) API that can be found here : http://www.thinkingcleaner.com/setup/api/#API
As far as I can see sending commands can be done through sending a "http command"

Example:
Code: Select all
Clean
This command starts a cleaning cycle like pressing the 'Clean' button on the Roomba. When Roomba is
sleeping this command will wake Roomba first and execute the Dock command. When Roomba is cleaning,
this command will stop the Roomba.
Example:
http://thinking.local/command.json?command=clean
returns:
{
 "action" : "clean",
 "result" : "success
}


So I thought I should start playing around a little with this. I have also gone through the Indigo documentation: http://wiki.indigodomo.com/doku.php?id=indigo_5_documentation:plugin_guide

So my first question is what software is recommended for this kind of programming? And if anyone has some useful tips, please share them :)

Håvard

Posted on
Mon Jan 25, 2016 1:07 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Making my first plugin : ThinkingCleaner for Roomba

Are you Mac or Windows?

Use the integrated scripting shell from Indigo to test lines of code live. Eg exploring the return value of that example, so you know your URL call is correct, and you can parse the JSON. Quicker than re-running your plugin every few lines.


Sent from my iPhone using Tapatalk

Posted on
Mon Jan 25, 2016 1:10 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Making my first plugin : ThinkingCleaner for Roomba

I am on a mac. And I dont understand what you are saying about the JSON
So there you have my level for this project :)

Håvard

Posted on
Mon Jan 25, 2016 9:03 am
jheddings offline
User avatar
Posts: 149
Joined: Dec 01, 2013
Location: Denver, CO

Re: Making my first plugin : ThinkingCleaner for Roomba

All plugins are done in Python. A nice advantage of this approach is that you can use any text editor you like and even make changes to your plugin on the fly. The best way to get started is use the SDK, which contains plugin examples. Many of the plugins you would want to create can be derived from those examples.

Also, be sure to study the Plugin Tutorial carefully... There is a lot of good information in there.

Posted on
Mon Jan 25, 2016 4:53 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Making my first plugin : ThinkingCleaner for Roomba

haavarda wrote:
So I thought I should start playing around a little with this. I have also gone through the Indigo documentation: http://wiki.indigodomo.com/doku.php?id=indigo_5_documentation:plugin_guide

So my first question is what software is recommended for this kind of programming? And if anyone has some useful tips, please share them :)


Note: the link above is to the Indigo 5 docs, so you'll want the Indigo 6 version.

As others have pointed out, plugins are just a structured directory with some files in it. For simple plugins, I use BBEdit (though TextWrangler would work as well) and for more complex plugins I use PyCharm - it's not cheap, but is an amazingly good Python IDE. Any plain text editor will work - just make sure it's meant for plain text editing so it doesn't do things like make quotes smart, etc. (TextEdit is not particularly good because it wants to do rich text).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jan 25, 2016 5:37 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Making my first plugin : ThinkingCleaner for Roomba

haavarda wrote:
And I dont understand what you are saying about the JSON
So there you have my level for this project :)

Don't take this wrong, but you're going to have fun then!

However the sense of achievement when you publish the plugin and others start using it will be worth the time you've put into it.

When I started the Evohome plugin, I'd forgotten about the scripting shell you can launch from indigo. I was therefore writing code in my plugin that retrieved an object from Honeywell containing data about my thermostats, then having it write the data in the object to the log so I could see what it contained. Then write some more code to do something with it, then save and update my plugin to test it. Again. And again. And a few more times for good measure.

With the scripting shell, I could explore the object live, seeing what it contained, trying things, then when I got the data I wanted (temperature) I could just copy the necessary lines of code into my plugin, once, and test it.

(Note for any devs following, yes I could and did use the Python terminal straight up, but that meant keeping a separate set of code to load and save variables from IPH every time I logged in)


Sent from my iPhone using Tapatalk

Posted on
Tue Jan 26, 2016 2:28 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Making my first plugin : ThinkingCleaner for Roomba

I have found a Python code on GitHub that communicates with the thinkingcleaner.
https://github.com/edent/ThinkingCleaner-WiFi-Roomba-Python/blob/master/roomba.py
I will remove the twitter part, and instead update the indigo device. Can someone have a quick look at that code and see if there is any immediate problems?

Is for instance the libraries below supported?

import json
import requests
import sys
import os
import locale

It is referred to a json file. Is this a file that is stored with the plugin? Or is this a temp file?

Håvard

Posted on
Tue Jan 26, 2016 10:50 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Making my first plugin : ThinkingCleaner for Roomba

There are a few things to consider: first, the json module wasn't included until Python 2.6 (which is only explicitly used with Indigo 6.1 and greater). However, we included it's predecessor with Indigo. So, if you put this at the top of the Python file in your plugin, json will work either way:

Code: Select all
try:
    import json
except:
    import simplejson as json


Next, the requests library isn't included with Python, so you'll either need to instruct your users to install it first, or possibly include it with your plugin. I'm not sure if it's pure Python or not (I think it is) so including it would probably work with a little effort. Note, however, that it requires Python 2.6, so your plugin would be limited to Indigo 6.1+.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jan 26, 2016 12:12 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Making my first plugin : ThinkingCleaner for Roomba

I include Requests with my Evohome plugin, but I've not tested earlier releases of Indigo.


Sent from my iPhone using Tapatalk

Posted on
Wed Jan 27, 2016 6:58 pm
keifer1 offline
Posts: 87
Joined: Oct 21, 2012

Re: Making my first plugin : ThinkingCleaner for Roomba

The link on thinking cleaner web site is not active.

http://www.thinkingcleaner.com/setup/api/#Indigo

Indigo Domotics:Indigo domotics
For indigo (http://www.indigodomo.nl) a plugin is in development.

FYI. Thanks for the work , lets roomba

Computer Keith
Mt Pleasant SC - Charleston
Indi-Go -Go-Go

Posted on
Wed Jan 27, 2016 7:10 pm
keifer1 offline
Posts: 87
Joined: Oct 21, 2012

Re: Making my first plugin : ThinkingCleaner for Roomba

Check this thread out:

viewtopic.php?f=5&t=10940&p=107117&hilit=roomba#p107117

tenallero wrote:
Hi,

Apologies to be so late.

This link points to the documentation about my Roomba plugin:
https://www.dropbox.com/s/9ghepfwbxdaw0 ... plugin.pdf

Inside you will find the link to download the code and setup instructions.

Some notes about it:
English is not my language. So, apologies about any linguistic incorrection.
I have publish it as a PDF file, because I have not found the correct way to do it as a readable forum entry (mainly about including pictures from my desktop)
The code is open. I will find the way to publish it on github or similar.
This plugin is my first Indigo's plugin and my first lines of python code. I would like to thank to Dan Noguerol (https://bitbucket.org/whizzosoftware/in ... ddy-plugin), because his work around "irrigation caddy plugin" give me inspiration and confidence to start coding a python plugin for Indigo.
Also congratulate Matt and Jay with the well done work with Indigo. It has been a nice experience to develop an Indigo plugin and collaborate with Matt testing some Fibaro's zwave devices.


Stoffergoffer, you opened the thread. Next point will be about XBMC and PiFace plugin.

Regards,

Ramon

Computer Keith
Mt Pleasant SC - Charleston
Indi-Go -Go-Go

Posted on
Wed Jan 27, 2016 7:16 pm
keifer1 offline
Posts: 87
Joined: Oct 21, 2012

Re: Making my first plugin : ThinkingCleaner for Roomba

Their were some great under counter pics of the rumbas hiding place .

Computer Keith
Mt Pleasant SC - Charleston
Indi-Go -Go-Go

Posted on
Thu Jan 28, 2016 6:42 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Making my first plugin : ThinkingCleaner for Roomba

I have been through the thread in the forum post above. And at the bottom you can see that I have asked if the user can share his plugin.
None of the dropbox links above seams to be working. I also think that tenallero posted his old plugin, not the one for thinkingcleaner.

Håvard

Posted on
Thu Jan 28, 2016 11:58 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Making my first plugin : ThinkingCleaner for Roomba

keifer1 wrote:
Indigo Domotics:Indigo domotics
For indigo (http://www.indigodomo.nl) a plugin is in development.


We don't own http://www.indigodomo.nl - nobody does. I think whoever submitted it to them needs to update it to http://www.indigodomo.com/

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jan 28, 2016 1:41 pm
keifer1 offline
Posts: 87
Joined: Oct 21, 2012

Re: Making my first plugin : ThinkingCleaner for Roomba

Hear is a link to some of his original posts. I'm will look to see if I have a copy of the plugin. Never ordered the wifi but your post reminded me of it. Looking forward to testing your plugin, going to order the wifi fi adapter.

Think this still works. Show under cabinet install.
https://www.dropbox.com/sh/3dz6mbrwyw9nlyu/HqSKh_b_YY

Computer Keith
Mt Pleasant SC - Charleston
Indi-Go -Go-Go

Who is online

Users browsing this forum: No registered users and 15 guests