iRoomba iRobot Plugin

Posted on
Fri Sep 24, 2021 9:55 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

I see. The date/time is fine as is, I can get at the time. If you make it customizable, I'll make use of that...

Regarding the currentstate, my only "wish list item" would be to be mindful of the length. The statement "Running, Mission duration [xx] minutes" is a good length. Much wider than that and I'd have a challenge fitting it into an attractive, easily-viewable interface element... (IMO)

Keep up the great work, and thanks again!

PS. I have an extensive interface for my Roomba on a "System" page, but on my "Home" page I have this:
Attachments
roomba1.png
roomba1.png (26.44 KiB) Viewed 6088 times

Posted on
Sat Sep 25, 2021 10:44 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: iRoomba iRobot Plugin

Hi Mark

Have a try of 0.9.0 and/or 0.9.1.

In the commits at github I update any other changes - often add a few things after posting! Not that you haven't figured it all out anyway!

Changelog:

0.9.1
Some changes to currentstate_Statement - shortening mission time statement but adding Battery
eg.
Running, Mission 25 mins, Bat 45%

0.9.0
Change connection & reconnection to threaded events to avoid hang if one device unavailable/unstable as I recent found
Modifications to currentState_statement - more information
Add Datetime modification to Plugin Config. Change this to change the Mission/Recharge datetimes format to
Sun 2:04PM to 02/2/2021 02:23:22 see examples or webpage link

0.8.9
Add currentState_statement state:
Aiming to describe what is happening in sentence for control pages
eg. Charging, restarting Mission in 48 minutes
Error etc.
Ideally replacing status in control pages...

0.8.6
Change Lifetime Runtime to English string weeks,days,minutes etc
Add Mission Duration state in minutes
Add LifeTimeCleaningJobs run state
Add LifeTime Area Cleaned in M2 and Sqft
Slight changes to status info; update midMsn state

0.8.5
Add Lifetime Runtime state Hours, Minutes
Add Mission Started Date time state
Fix RechargeMinutes remaining for later models - had to calculate. Change to a number to allow triggering with greater than/equal to etc.
Add Recharge Finish Date stamp as a stamp
Last edited by GlennNZ on Sun Sep 26, 2021 12:23 am, edited 1 time in total.

Posted on
Sat Sep 25, 2021 11:46 pm
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

But I just got the previous version working!! :lol:

I'll check it out and let you know how it goes...

(Might be a few days.)

Posted on
Sun Sep 26, 2021 12:41 am
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

iRoomba iRobot Plugin

No rush.

No breaking changes - to either triggers/maps/states/devices.. pretty careful these days and normally can avoid.

The date time is infinitely customisable from PluginConfig, for both the MissionStarted and Recharge state. Also interested in Fine tuning the statement - happy to take suggestions - with the aim being to incorporate everything into this own field.

Glenn


Sent from my iPad using Tapatalk

Posted on
Sun Sep 26, 2021 11:55 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

Cool. I've been studying your Python, even before this latest update. I think it's great that you are both providing the "raw" states, and this new "human-friendly" state. Someone not python-savvy (and even those who are "literate") will appreciate your efforts in providing a single, meaningful status statement. And for geeks like me, I can use that, and also enhance my interface by using the other states.

For example, I'm displaying your new state in my interface, and right below that I display my own version. It goes a bit more into detail (like when the base is emptying the bin), and also tracks which of my missions just ran. Helpful because my old brain was forgetting which part of my house was just vacuumed!

So I think you've got the best-of-both in the choices you made in what states to reveal, and how you reveal them.

I've been watching what the iRobot app reports at the same time I watch what your plug-in reports. So, for example, one of my notifications translates the ominous "undocumented #39" into "Saving clean map..." I have another for #68. My notifications were somewhat inspired by how the app reports various states.

Some of my efforts are now redundant, since you enhanced your statements. No matter. I'm just geeking in my usual way. (HA is a hobby for me.)

Here's what I've been doing, if it's of interest to you. Like your efforts, it's a work in progress. "roomba_message" is the variable I use to elaborate on your statements. "roomba_mission" is the variable I use to track which vac job I last initiated. It contains the name of a room or area. This code is triggered whenever either of a couple of your states change.


Code: Select all

from datetime import datetime

vRoombaMissionStarted = (indigo.devices[765723352].states["MissionStarted"]) # "Roomba"
vRoombaRechargeFinish = (indigo.devices[765723352].states["RechargeFinish"]) # "Roomba"
vRoombaRechargeM = (indigo.devices[765723352].states["RechargeM"]) # "Roomba"
vRoombaNotReadyText = (indigo.devices[765723352].states["NotReadyText"]) # "Roomba"
vRoombaDeviceStatus = (indigo.devices[765723352].states["deviceStatus"]) # "Roomba"
vRoombaMission = (indigo.variables[1281672395].value) # "roomba_mission"


if unicode(vRoombaRechargeFinish) != '':
   try:
      datetime_object = datetime.strptime(vRoombaRechargeFinish, '%a %b %d %H:%M:%S %Y')
      vAmPmTime = datetime_object.strftime('%-I:%M:%S%p')
      indigo.variable.updateValue(1719512708, value='Will resume at ' + unicode(vAmPmTime).lower())  # "roomba_message"
   except:
      indigo.server.log('Trigger "Roomba Messages" script error', type="Trigger Script", isError=True)
elif unicode(vRoombaDeviceStatus) == 'Battery Low':
   indigo.variable.updateValue(1719512708, value='Battery low')  # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'End Mission':
   indigo.variable.updateValue(1719512708, value='Returning home...')  # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Returning to Base':
   indigo.variable.updateValue(1719512708, value='Returning to base...')  # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Emptying':
   indigo.variable.updateValue(1719512708, value='Emptying bin...')  # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Cancelled':
   indigo.variable.updateValue(1719512708, value='Cancelled...')  # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Stopped':
   indigo.variable.updateValue(1719512708, value='Stopped')  # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'User Docking':
   indigo.variable.updateValue(1719512708, value='User docking...')  # "roomba_message"
elif "39" in unicode(vRoombaDeviceStatus):
   indigo.variable.updateValue(1719512708, value='Saving clean map...')  # "roomba_message"
elif "68" in unicode(vRoombaDeviceStatus):
   indigo.variable.updateValue(1719512708, value='Saving smart map edits...')  # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Charging':
   indigo.variable.updateValue(1719512708, value='Ready (Last: ' + vRoombaMission + ')')  # "roomba_message"
elif unicode(vRoombaMissionStarted) != '':
   try:
      datetime_object = datetime.strptime(vRoombaMissionStarted, '%a %b %d %H:%M:%S %Y')
      vAmPmTime = datetime_object.strftime('%-I:%M%p')
      indigo.variable.updateValue(1719512708, value='Vacuuming ' + vRoombaMission + ' at ' + unicode(vAmPmTime).lower())  # "roomba_message"
   except:
      indigo.server.log('Trigger "Roomba Messages" script error', type="Trigger Script", isError=True)
else:
   if vRoombaNotReadyText == "Ready":
      indigo.variable.updateValue(1719512708, value='Ready (Last: ' + vRoombaMission + ')')  # "roomba_message"
   else:
      indigo.variable.updateValue(1719512708, value='Not ready...')  # "roomba_message"

Posted on
Mon Sep 27, 2021 1:39 am
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: iRoomba iRobot Plugin

Thanks

Have continued to fiddle and 0.9.2 as below.

Couple of bug fixes and add’s your reported Not Ready states.

The biggest fix was Not Ready text over rode Error text, that has been swapped.


0.9.2
Remove allRoomba check on start of every device. Was a bit overkill.
Format all Lifetime numbers as readable number = eg. 3,200 & make string.
Add Not Ready states as reported = States 39 & 68 (welcome to report more and can add)
Add State lastMission - reports the last Mission time Mission run, uses same datetime formatting as plugin Config
Reorder NotReady and Error messages; Error Message will outrank Not Ready for summary CurrentState display


Sent from my iPad using Tapatalk

Posted on
Mon Sep 27, 2021 1:58 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

I'll give 0.9.2 a whirl...

Posted on
Tue Sep 28, 2021 2:01 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

Had a chance to play with 0.9.2. Works great. And I see the new date format field in the config dialog. Nice. I haven't tried that yet, as my python is handling the %c format just fine. But I may give it a go at some point. Or let me know if you'd like me to test that.

I had to modify my trigger's code, as you changed some of the status text my code was translating, but that was easy.

I haven't done anything with errors, as my Roomba hasn't thrown any yet. What's an easy way to trigger an error? Pick it up? Or something like that? Just curious to see how your plug-in handles one...

Thanks again for the plug-in, and all the updates!

Now all you have left to do is the fun stuff, updating all the documentation!! :twisted:

Posted on
Tue Sep 28, 2021 2:07 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

PS, I don't have a use yet for the new lastMission state, but it is filling in correctly on my system.

Oh, and I like "ErrorText = None" better than "ErrorText = No Error".
Last edited by Mark on Tue Sep 28, 2021 2:12 am, edited 1 time in total.

Posted on
Tue Sep 28, 2021 2:09 am
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

iRoomba iRobot Plugin

Thanks

No time for documentation … there is already 0.9.3 with some moderate changes!

I decompiled the android iroomba app and borrowed their xml file with all the error and not-ready codes. Have manually added the short version for all of these.

But also added the whole xml file as a json file. This includes all iroombas statements based on errors not ready codes etc.

Added new field:
errornotready_statement
Basically checks this iroomba dataset and if error exists will report it like the iroomba app
“Move Upstairs to a flat surface and press Clean”
For example - does also swap in devices name

Also
If charging and fully charged will say
“Fully Charged. Ready to vacuum”.
Rather than charging, battery 100%



Glenn


Sent from my iPhone using Tapatalk

Posted on
Tue Sep 28, 2021 9:47 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

I like that last one. Always bugged me that my interface read "Charging" while the battery is at 100%.

Posted on
Tue Sep 28, 2021 11:04 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

Got 0.9.3 installed.

Odd:

Statement reads "Fully charged. Ready to vacuum."
Battery is at 100.
But Status reads "Recharging"

How:
Some how I got my Roomba paused. Maybe I inadvertently hit my Pause button (not sure) while playing with the interface.
Status read "Paused." I tried to clear that by clicking my Resume button. That did nothing.
Then I tried my Dock button (while the Roomba was docked, and paused), and that initiated an evac.
But then Status read "Recharging." Still does (several minutes later).

I'll report if/when that changes. If it doesn't, I'll run a mission and see what happens...

Edit: 20 minutes laters, status still reads "Recharge", clicking my "Get Info" button does not reset status to charging
phase reads "charge"
NotReady = 0
NotReadyText = Undocumented Not Ready Value (0)

Edit: This might be a false alarm. I reloaded a fresh copy of 0.9.3 and all is well. I may have introduced an errant character while exploring your python. My bad...

Posted on
Tue Sep 28, 2021 3:01 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: iRoomba iRobot Plugin

Hi

The status will still read Charging - technically it’s true. It’s just the currentState_Statement that I have been updating with more human readable, combined info - that reads when battery is 100% “Full charged. Ready to Vacuum”. Same as app.

Try to leave old states alone as much as possible; particularly if their is triggering etc set up on them.

The NotReadyText I’ll look out for.

Have made some large additions with the iroomba xml file. Included the whole file as still pretty small memory wise and may find other aspects in there keen to use. If not will cut it down to the usable states in due course.


Sent from my iPad using Tapatalk

Posted on
Tue Sep 28, 2021 7:16 pm
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

GlennNZ wrote:
The status will still read Charging - technically it’s true. It’s just the currentState_Statement that I have been updating with more human readable, combined info - that reads when battery is 100% “Full charged. Ready to Vacuum”. Same as app.

Understood. But for some reason the Status state read "Recharging", not "Charging". I think it was something I did to your Python code.

GlennNZ wrote:
Try to leave old states alone as much as possible; particularly if their is triggering etc set up on them.

I appreciate that. But if they change, they change. My Trigger's code is easy to update... Plus, the more you fiddle with your currentState_Statement, the less my code has to do! :)

Posted on
Wed Sep 29, 2021 11:32 pm
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: iRoomba iRobot Plugin

OK, I gave the DateTime format configuration field a go. I used "%a, %b %d, %-I:%M:%S %p" and it works just fine.

I use that format as is in a control page element for a lastMission date/time stamp. I also convert that format to a few others in my Trigger code and that works fine, too.

Couple questions:

What is the difference between ErrorText, NotReadyText and errornotReady_Statement?

More importantly (for my interface needs): are any or all of those three reflected in the currentState_Statement when they are not "", "None" or "Ready"?

I can see the lists of self.errorStrings and self.notReadyStrings in your Python, but there seems to be a lot of overlap.

I'm currently only using ErrorText on a control page, along with currentState_Statement. So I'm wondering if anything useful would show up in NotReadyText or errornotReady_Statement that wouldn't already be covered by ErrorText or currentState_Statement...

Who is online

Users browsing this forum: No registered users and 1 guest