Skip to content

Commit

Permalink
0.2.5
Browse files Browse the repository at this point in the history
FIx for action error if not running continuous mode
Better handling actions if no connection possible/exists
Update Plugin Config to remind that continuous connection preferred method
  • Loading branch information
ghawken committed Jan 11, 2018
1 parent 0949b7c commit b7d5920
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion iRobot-Roomba.indigoPlugin/Contents/Info.plist
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>0.2.3</string>
<string>0.2.4</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>IwsApiVersion</key>
Expand Down
Expand Up @@ -19,7 +19,10 @@
</Field>

<Field id="continuous" type="checkbox" tooltip="Will keep connection to Roomba open." defaultValue="true">
<Label>Continous connection to ONE Roomba Device only. Do not enable if wish more than one Roomba controlled.</Label>
<Label>
Continous connection to ONE Roomba Device only. Do not enable if wish more than one Roomba controlled.
(This is the recommended setup )
</Label>
<Description>Enable/Disable</Description>
</Field>

Expand Down
48 changes: 34 additions & 14 deletions iRobot-Roomba.indigoPlugin/Contents/Server Plugin/plugin.py
Expand Up @@ -436,7 +436,7 @@ def saveMasterStateDevice(self, masterState, device, currentstate):
def disconnectRoomba(self,device):
self.logger.debug(u'disconnecting Roomba Device: '+unicode(device.name))

if self.myroomba != None and self.myroomba != None:
if self.myroomba != None:
if self.myroomba.master_state != None:
self.saveMasterStateDevice(self.myroomba.master_state, device, "")
self.logger.debug(unicode(self.myroomba.master_state))
Expand All @@ -461,6 +461,8 @@ def getRoombaInfo(self, device):
time.sleep(15)
if self.continuous == False:
self.disconnectRoomba(device)


return

def updateMasterStates(self, current_state):
Expand Down Expand Up @@ -557,16 +559,34 @@ def dockRoombaAction(self, pluginAction, roombaDevice):

def RoombaAction(self, pluginAction, roombaDevice, action):
self.logger.debug(u"startRoombaAction for "+unicode(roombaDevice.name)+": Action : "+str(action))
if self.connected == False and self.continuous== False:
self.connectRoomba(roombaDevice)
time.sleep(5)
self.myroomba.send_command(str(action))
time.sleep(5)
self.disconnectRoomba(roombaDevice)
if self.connected == True:
#self.connectRoomba(roombaDevice)
#time.sleep(5)
self.myroomba.send_command(str(action))
time.sleep(5)
if self.continuous == False:
self.disconnectRoomba(roombaDevice)
# Add a try except loop to catch nicely any errors.
try:
if self.connected == False and self.continuous== False:
connected = False
connected = self.connectRoomba(roombaDevice)
time.sleep(5)
# Add a connection check - the main library has added a base exception which might be useful to also use.
if connected == False:
self.logger.info(u'Failed Connected to Roomba within 5 seconds, waiting another 5.')
time.sleep(5)
if connected == False:
self.logger.info(u'Failed Connected to Roomba within 5 seconds. Ending attempt.')
return

self.myroomba.send_command(str(action))
time.sleep(5)
self.disconnectRoomba(roombaDevice)
time.sleep(5)
return

if self.connected == True:
#self.connectRoomba(roombaDevice)
#time.sleep(5)
self.myroomba.send_command(str(action))
time.sleep(5)
if self.continuous == False:
self.disconnectRoomba(roombaDevice)
return

except Exception as e:
self.logger.debug(u'Error within RoombaAction:'+unicode(e))

0 comments on commit b7d5920

Please sign in to comment.