Skip to content

Commit

Permalink
0.9.3
Browse files Browse the repository at this point in the history
Less logging if devices offline - remove startup check hopefully no setup issues
Leaves data intact - deviceLastUpdated == last successful update
  • Loading branch information
ghawken committed Oct 20, 2018
1 parent 41d610b commit 4f58ac2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion iFindFriendsMini.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>0.9.1</string>
<string>0.9.3</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>CFBundleDisplayName</key>
Expand Down
61 changes: 40 additions & 21 deletions iFindFriendsMini.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,25 +1061,43 @@ def refreshDataForDev(self, dev, follow):
#
#Check for no data received and handle avoiding exception
#unless starting up (60 seconds only)
if self.startingUp==False:
if follow is None or 'location' not in follow:
self.logger.debug(u'No data received for device:'+unicode(dev.name)+' . Most likely device is offline/airplane mode or has disabled sharing location')
if dev.states['deviceIsOnline']:
self.logger.info(u'Friend Device:'+unicode(dev.name)+' has become Offline. Most likely offline/airplane mode or disabled sharing')
dev.updateStateOnServer('deviceIsOnline', value=False, uiValue='Offline')
dev.updateStateImageOnServer(indigo.kStateImageSel.SensorOff)
return
#if self.startingUp==False or self.startingUp==True:
if follow is None:
self.logger.debug(u'No data received for device:' + unicode(
dev.name) + ' . Most likely device is offline/airplane mode or has disabled sharing location')
if dev.states['deviceIsOnline']:
self.logger.info(u'Friend Device:' + unicode(
dev.name) + ' has become Offline. Most likely offline/airplane mode or disabled sharing')
dev.updateStateOnServer('deviceIsOnline', value=False, uiValue='Offline')
dev.updateStateImageOnServer(indigo.kStateImageSel.SensorOff)
return
if 'location' not in follow:
self.logger.debug(u'No data received for device:' + unicode(
dev.name) + ' . Most likely device is offline/airplane mode or has disabled sharing location')
if dev.states['deviceIsOnline']:
self.logger.info(u'Friend Device:' + unicode(
dev.name) + ' has become Offline. Most likely offline/airplane mode or disabled sharing')
dev.updateStateOnServer('deviceIsOnline', value=False, uiValue='Offline')
dev.updateStateImageOnServer(indigo.kStateImageSel.SensorOff)
return
if follow['location'] is None or follow['location'] == 'None':
self.logger.debug(u'No data received for device:'+unicode(dev.name)+' . Most likely device is offline/airplane mode or has disabled sharing location')
if dev.states['deviceIsOnline']:
self.logger.info(u'Friend Device:'+unicode(dev.name)+' has become Offline. Most likely offline/airplane mode or disabled sharing')
dev.updateStateOnServer('deviceIsOnline', value=False, uiValue='Offline')
dev.updateStateImageOnServer(indigo.kStateImageSel.SensorOff)
return


UseLabelforState = False
# Deal with Label Dict either Dict or None
labels=''
if follow is not None:
if 'location' in follow:
if 'labels' in follow['location'] and follow['location']['labels'] is not None:
labels = follow['location']['labels']
else:
labels =''
if follow['location'] is not None:
if 'labels' in follow['location']:
if follow['location']['labels'] is not None:
labels = follow['location']['labels']
#another none check - shouldnt be needed
if len(labels) > 0:
label = labels[0]
Expand All @@ -1106,13 +1124,14 @@ def refreshDataForDev(self, dev, follow):
address =""
if follow is not None:
if 'location' in follow:
if 'address' in follow['location'] and follow['location']['address'] is not None:
if 'formattedAddressLines' in follow['location']['address'] and follow['location']['address']['formattedAddressLines'] is not None:
address = ','.join(follow['location']['address']['formattedAddressLines'])
if 'streetAddress' in follow['location']['address'] and follow['location']['address']['streetAddress'] is not None:
address = follow['location']['address']['streetAddress']
if 'locality' in follow['location']['address'] and follow['location']['address']['locality'] is not None:
address = address + ' '+ follow['location']['address']['locality']
if follow['location'] is not None:
if 'address' in follow['location'] and follow['location']['address'] is not None:
if 'formattedAddressLines' in follow['location']['address'] and follow['location']['address']['formattedAddressLines'] is not None:
address = ','.join(follow['location']['address']['formattedAddressLines'])
if 'streetAddress' in follow['location']['address'] and follow['location']['address']['streetAddress'] is not None:
address = follow['location']['address']['streetAddress']
if 'locality' in follow['location']['address'] and follow['location']['address']['locality'] is not None:
address = address + ' '+ follow['location']['address']['locality']

if dev.states['latitude'] != 'unknown':
iDevLatitude = float(dev.states['latitude'])
Expand Down Expand Up @@ -1162,8 +1181,8 @@ def refreshDataForDev(self, dev, follow):
return

except Exception as e:
self.logger.info(unicode('Exception in refreshDataforDev: ' + unicode(e)))
self.logger.exception('Exception:')
self.logger.debug(unicode('Exception in refreshDataforDev: ' + unicode(e)))
self.logger.debug('Exception:')
self.logger.info(unicode('Possibility missing some data from icloud: Is your account setup with FindFriends enabled on iOS/Mobile device?'))
dev.updateStateOnServer('deviceIsOnline', value=False, uiValue='Offline')
dev.updateStateImageOnServer(indigo.kStateImageSel.SensorOff)
Expand Down

0 comments on commit 4f58ac2

Please sign in to comment.