Making my first plugin : ThinkingCleaner for Roomba

Posted on
Fri Jan 29, 2016 2:00 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Making my first plugin : ThinkingCleaner for Roomba

I have now been playing a bit with the TC (ThinkingCleaner) module, and I dont think this has to be verry complicated. I am able to set commands and get status from url commands in safari. I am confident I could have done this with action groups with python snippets and variables, but off course it is much more tidy and clean to have a separate plugin.

So what I want the plugin to do and collect is as follows:

1 Store the IP address of the roomba.
2 Execute actions. Clean, dock, max, etc.
These actions follow a pattern like this :
Code: Select all
   http://ipaddress /command.json?command=clean
    returns:
   {
    "action" : "clean",
    "result" : "success
   }

So after a command is executed the state should be updated accordingly, and a status should be polled.

3 Polling status from the roomba is also done with a http request that returns the status:
Code: Select all
http://ipaddress/status.json returns:
   {
    "action" : "status",
    "result" : "success",
    "status" : {
    “name” : “Thinking”,
    "battery_charge" : 100,
    "capacity" : "2696",
    "cleaner_state" : "st_base_full",
    "cleaning" : "0",
    "schedule_serial_number" : “12”,
    "near_homebase" : "0"
    }
   }

These values needs to be updated as states in the device in the plugin.

4 Periodically polling.
In order to pick up manual activation or other feedback from the roomba the device should be polled for status at set intervals. I am thinking that it should be polled more often when running that when in standby.

Since I am at best a beginner at this sort of programming, I am hoping that someone can point me in the right direction. Anyone has any sugestion for an existing plugin that I can get some ideas and inspiration from? :)

Håvard

Posted on
Sat Feb 20, 2016 8:52 am
tenallero offline
Posts: 94
Joined: Oct 31, 2011
Location: Barcelona

Re: Making my first plugin : ThinkingCleaner for Roomba

Hi,

I have just published a "Thinking Cleaner" plugin
https://github.com/tenallero/Indigo-Thi ... eaner/wiki

Posted on
Mon Feb 22, 2016 1:27 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Making my first plugin : ThinkingCleaner for Roomba

Excellent. I am going to try it out later today. :)
Just out of curiosity I see that there is some lines about authentication in your code. What is this about?

Håvard

Posted on
Mon Feb 22, 2016 2:23 am
tenallero offline
Posts: 94
Joined: Oct 31, 2011
Location: Barcelona

Re: Making my first plugin : ThinkingCleaner for Roomba

This plugin comes from a previous plugin (RooWifi) that was using authentification as an option.

Posted on
Mon Mar 07, 2016 5:17 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Making my first plugin : ThinkingCleaner for Roomba

Hi tenallero the plugin is working very well. Thank you for your work.

Could it be possible to add a state with the full status text from the thinking cleaner module? For example: On homebase trickle charging
I want to display the status on a control page and can't find this full state..?

Could it also be possible to change the polling intervals? When using the web hook feature I assume a more seldom pooling is required, it would be nice to set this timer by user input.

Thanks again.

Håvard

Posted on
Mon Mar 07, 2016 5:26 am
tenallero offline
Posts: 94
Joined: Oct 31, 2011
Location: Barcelona

Re: Making my first plugin : ThinkingCleaner for Roomba

haavarda wrote:
Hi tenallero the plugin is working very well. Thank you for your work.

Could it be possible to add a state with the full status text from the thinking cleaner module? For example: On homebase trickle charging
I want to display the status on a control page and can't find this full state..?

Could it also be possible to change the polling intervals? When using the web hook feature I assume a more seldom pooling is required, it would be nice to set this timer by user input.

Thanks again.


Thanks for testing it

About "control pages" ... is one of the Indigo's features I want to learn, but no experience on it.
I will try to improve my knowledges, and change the plugin

When using webhook ... is the Roomba device who pools to Indigo.
If a webhook event arrives to Indigo, the pooling time counter resets.

How much do you want to change the pooling intervals?

Posted on
Mon Mar 07, 2016 11:26 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Making my first plugin : ThinkingCleaner for Roomba

Ok. I was thinking that the polling was constant. But if there is more logic to it, then that changes things. I guess that scheduled polling is less required when using web hook. Only to report battery charge as it seems this is not updated when cleaning or charging.

Håvard

Posted on
Mon Mar 07, 2016 6:50 pm
tenallero offline
Posts: 94
Joined: Oct 31, 2011
Location: Barcelona

Re: Making my first plugin : ThinkingCleaner for Roomba

haavarda wrote:
Hi tenallero the plugin is working very well. Thank you for your work.

Could it be possible to add a state with the full status text from the thinking cleaner module? For example: On homebase trickle charging
I want to display the status on a control page and can't find this full state..?

Could it also be possible to change the polling intervals? When using the web hook feature I assume a more seldom pooling is required, it would be nice to set this timer by user input.

Thanks again.


About the "full status text" new state:
I don´t think is correct to add a new state having an existing state that provides the basic "value"

I have been thinking, and I think the answer is create an Indigo´s variable to hold the literature you need for your control page.
This variable will be feed using triggers based on changes for the device state.

Trigger device = Device state Changed
Device = (Your Roomba)
Roomba is Docked
Becomes True

Actions
Variable Actions. Modify Variable
Variable = (The variable´s name to store full text state)
Set to: "My Roomba is docked or whatever you want"

[Create as many triggers as states using the same variable]

Posted on
Tue Mar 08, 2016 12:46 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Making my first plugin : ThinkingCleaner for Roomba

I understand that I can do this with triggers and variables. But my thought was that having a variable that contains cleaner state as described in the thinking cleaner API would be useful. At least a state that shows the "raw state" then I can translate it my self, that is no problem.

Code: Select all
- cleaner_state gives back left column. Right is the text message associated:
st_base On homebase: Not Charging
st_base_recon On homebase: Reconditioning Charging
st_base_full On homebase: Full Charging
st_base_trickle On homebase: Trickle Charging
st_base_wait On homebase: Waiting
st_plug Plugged in: Not Charging
st_plug_recon Plugged in: Reconditioning Charging
st_plug_full Plugged in: Full Charging
st_plug_trickle Plugged in: Trickle Charging
st_plug_wait Plugged in: Waiting
st_stopped Stopped
st_clean Cleaning
st_cleanstop Stopped with cleaning
st_clean_spot Spot cleaning
st_clean_max Max cleaning
st_delayed Delayed cleaning will start soon ..
st_dock Searching Homebase
st_pickup Roomba picked up
st_remote Remote control driving
st_wait Waiting for command
st_off Off
st_error Error
st_locate Find me!
st_unknown Unknown state

Håvard

Posted on
Tue Mar 08, 2016 4:11 am
tenallero offline
Posts: 94
Joined: Oct 31, 2011
Location: Barcelona

Re: Making my first plugin : ThinkingCleaner for Roomba

haavarda wrote:
I understand that I can do this with triggers and variables. But my thought was that having a variable that contains cleaner state as described in the thinking cleaner API would be useful. At least a state that shows the "raw state" then I can translate it my self, that is no problem.

Code: Select all
- cleaner_state gives back left column. Right is the text message associated:
st_base On homebase: Not Charging
st_base_recon On homebase: Reconditioning Charging
st_base_full On homebase: Full Charging
st_base_trickle On homebase: Trickle Charging
st_base_wait On homebase: Waiting
st_plug Plugged in: Not Charging
st_plug_recon Plugged in: Reconditioning Charging
st_plug_full Plugged in: Full Charging
st_plug_trickle Plugged in: Trickle Charging
st_plug_wait Plugged in: Waiting
st_stopped Stopped
st_clean Cleaning
st_cleanstop Stopped with cleaning
st_clean_spot Spot cleaning
st_clean_max Max cleaning
st_delayed Delayed cleaning will start soon ..
st_dock Searching Homebase
st_pickup Roomba picked up
st_remote Remote control driving
st_wait Waiting for command
st_off Off
st_error Error
st_locate Find me!
st_unknown Unknown state


Please, try this new release
https://github.com/tenallero/Indigo-Thi ... Plugin.zip

Apart of new state for your, you will find new functionalities about device discovery not yet documented on wiki.

Posted on
Wed Mar 23, 2016 1:12 am
kwijibo007 offline
Posts: 325
Joined: Sep 27, 2013
Location: Melbourne, Australia

Re: Making my first plugin : ThinkingCleaner for Roomba

Hi tenallero,

Thanks for the plugin!

I just received my thinking cleaner and have tested out the plugin. When Roomba is docked and I trigger a clean or undock from the plugin, Roomba doesn't undock gracefully by reversing but bashes forward against the dock. It's as if Roomba doesn't realise that it's docked. When I trigger a clean from the Thinking Cleaner app it's works normally.

My Roomba is a 630.

I noticed in the Indigo device settings that the "Type" is a "tc500". Should this be 600? I can't change the setting, it's greyed out.

Any thoughts?

Pete

Posted on
Wed Mar 23, 2016 2:52 am
kwijibo007 offline
Posts: 325
Joined: Sep 27, 2013
Location: Melbourne, Australia

Re: Making my first plugin : ThinkingCleaner for Roomba

kwijibo007 wrote:
Hi tenallero,

Thanks for the plugin!

I just received my thinking cleaner and have tested out the plugin. When Roomba is docked and I trigger a clean or undock from the plugin, Roomba doesn't undock gracefully by reversing but bashes forward against the dock. It's as if Roomba doesn't realise that it's docked. When I trigger a clean from the Thinking Cleaner app it's works normally.

My Roomba is a 630.

I noticed in the Indigo device settings that the "Type" is a "tc500". Should this be 600? I can't change the setting, it's greyed out.

Any thoughts?

Pete


On further investigation:

Sending this command http://thinking.local/command.json?comm ... vehomebase via a web browser has the same bad result... Roomba head buts the docking station. Maybe my Roomba (630) doesn't support this functionality? I'll email the Thinking Cleaner guys to find out.

Sending this command http://thinking.local/command.json?command=clean via the web browser has the correct result, Roomba gracefully backs out of the dock and starts cleaning. As noted above, using the plugin to send the clean command results in Roomba head butting the docking station. What command are you sending within the plugin?

Pete

Posted on
Wed Mar 23, 2016 3:02 am
tenallero offline
Posts: 94
Joined: Oct 31, 2011
Location: Barcelona

Re: Making my first plugin : ThinkingCleaner for Roomba

kwijibo007 wrote:
Hi tenallero,

Thanks for the plugin!

I just received my thinking cleaner and have tested out the plugin. When Roomba is docked and I trigger a clean or undock from the plugin, Roomba doesn't undock gracefully by reversing but bashes forward against the dock. It's as if Roomba doesn't realise that it's docked. When I trigger a clean from the Thinking Cleaner app it's works normally.

My Roomba is a 630.

I noticed in the Indigo device settings that the "Type" is a "tc500". Should this be 600? I can't change the setting, it's greyed out.

Any thoughts?

Pete


Hi Pete,

As I indicate in the wiki, The plugin offers two basic operations mapped as indigo switch on/off standard operations (like a lamp or a plug).
So you can operate your Roomba easily from Indigo´s Touch iOS app.

When you trigger "switch on" the plugin does two things: "Leave dock (gracefully)" and then "start cleaning".
When you trigger "switch off" the plugin does: "Return to dock".

Switch on/off does not appear in "Thinking Cleaner actions" menu. They appear as "device actions menu" because they are "standard" device´s actions.

I take note of your observations, and I will improve the plugin.
So, if you trigger "start cleaning", and the Roomba is docked, trigger an "undock action" automatically previous to cleaning.

Does this answer you question?

About type "tc500":
This information comes from the ThinkingCleaner device.
I think this is not the type of Roomba. It is the type of TC device (TC = ThinkingCleaner)
At this moment, this property (type tc500), does not affect the behaviour of the plugin.

Posted on
Wed Mar 23, 2016 3:15 am
tenallero offline
Posts: 94
Joined: Oct 31, 2011
Location: Barcelona

Re: Making my first plugin : ThinkingCleaner for Roomba

kwijibo007 wrote:
kwijibo007 wrote:
Hi tenallero,

Thanks for the plugin!

I just received my thinking cleaner and have tested out the plugin. When Roomba is docked and I trigger a clean or undock from the plugin, Roomba doesn't undock gracefully by reversing but bashes forward against the dock. It's as if Roomba doesn't realise that it's docked. When I trigger a clean from the Thinking Cleaner app it's works normally.

My Roomba is a 630.

I noticed in the Indigo device settings that the "Type" is a "tc500". Should this be 600? I can't change the setting, it's greyed out.

Any thoughts?

Pete


On further investigation:

Sending this command http://thinking.local/command.json?comm ... vehomebase via a web browser has the same bad result... Roomba head buts the docking station. Maybe my Roomba (630) doesn't support this functionality? I'll email the Thinking Cleaner guys to find out.

Sending this command http://thinking.local/command.json?command=clean via the web browser has the correct result, Roomba gracefully backs out of the dock and starts cleaning. As noted above, using the plugin to send the clean command results in Roomba head butting the docking station. What command are you sending within the plugin?

Pete


Hi Pete,
unfortunately my Roomba is Series 5XX, not 630 like your.
So, I can not reproduce the problem.

If you contact ThinkingCleaner team, let us know about any useful information to improve this plugin ,
The ThinkingCleaner team know the existance of this plugin for Indigo.

Regards,
Ramon

Posted on
Wed Mar 23, 2016 3:19 am
kwijibo007 offline
Posts: 325
Joined: Sep 27, 2013
Location: Melbourne, Australia

Re: Making my first plugin : ThinkingCleaner for Roomba

Thanks Ramon, will do.

Can you just confirm what json command you are sending within the plugin to start a clean? This works correctly when I send the json command from the browser but it head buts the dock in your plugin.

Pete

Who is online

Users browsing this forum: No registered users and 11 guests