Skip to content

Commit

Permalink
1.6.03
Browse files Browse the repository at this point in the history
Remove Logging error messaging
Update moving to Secure Remote Password for all logins.
Using SRP library == 1.0.21
Move to API > 3.4 to manage requirements processing as have not included library  (older versions will need to manually pip install srp==1.0.21)
Non significant code change.
Will need re-authenication with all 2FA codes once and then should keep going..
Any issues Delete plugin account (from Plugin Config) and try again.
Remove some logging, fix for exception messaging when should be passed if not fmip exists

1.5.10
Fix for 2fa trigger

1.5.9
Fix for myDevices in triggering being empty.

1.5.8
Check for empty data before using

1.5.6
Argh - more deletion of endpoints from apple
This is a quick 'monkey-fix' to get up and going after Apple deletes all the Friends endpoints.
Working in my brief testing - will check more when able/time.
Essentially this removes support for friend devices as end point is gone.
(as before big fix change devices to Family sharing type)

1.5.5
Add address city, suburb, country, house number, road - state to Family devices to construct own address string.
address = summary string, which is quite long

1.5.3
Use OSM to generate address data from lat/Long as no longer supplied by apple device
Update WazeRouteCaculator

1.5.2
Update Waze Router Calculator
Add labels to family devices

1.5.1

Apple has big server changes which this is a response to.

Remove support for 'Friends'.  Bugger.

What does this mean?
It means we can no longer access Friend data in any fashion.
We can access Family and Own Device data (every family device, and every personal device)

What does this mean?
Well I suspect most usage is within Families, so I would go into current iFriendDevice and edit it to iFriend Family device.
Save and restart Plugin - hopefully everything now continues

non-2FA accounts have largely been depreciated given back end issues.
  • Loading branch information
Ghawken committed Nov 1, 2024
1 parent eb0da5d commit 0020972
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 51 deletions.
8 changes: 4 additions & 4 deletions iFindFriendsMini.indigoPlugin/Contents/Server Plugin/ghpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def install(self):
latestRelease = self.getLatestRelease()

if (latestRelease == None):
self.logger.error('No release available')
self.logger.warn('No release available')
return False

try:
Expand Down Expand Up @@ -190,9 +190,9 @@ def _GET(self, requestPath):
self.logger.debug(u'Json results:'+unicode(data))
elif (400 <= f.status < 500):
error = json.loads(out)
self.logger.error('%s' % error['message'])
self.logger.warn('%s' % error['message'])
else:
self.logger.error('Error: %s' % unicode(err))
self.logger.warn('Error: %s' % unicode(err))

return data

Expand All @@ -203,7 +203,7 @@ def _prepareForUpdate(self, currentVersion=None):

# sort out the currentVersion based on user params
if ((currentVersion == None) and (self.plugin == None)):
self.logger.error('Must provide either currentVersion or plugin reference')
self.logger.warn('Must provide either currentVersion or plugin reference')
return None
elif (currentVersion == None):
currentVersion = str(self.plugin.pluginVersion)
Expand Down
88 changes: 45 additions & 43 deletions iFindFriendsMini.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,16 @@ def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs):
plugin = indigo.server.getPlugin('com.GlennNZ.indigoplugin.FindFriendsMini')

if MajorProblem == 1:
self.logger.error(u'Major Problem: Restarting Plugin...')
self.logger.warn(u'Major Problem: Restarting Plugin...')
if plugin.isEnabled():
plugin.restart(waitUntilDone=False)
self.sleep(1)
if MajorProblem == 2:
self.logger.error(u"{0:=^130}".format(""))
self.logger.error(u"{0:=^130}".format(""))
self.logger.error(u'Major Problem: Please Disable Plugin. Now Sleeping. Please contact Developer.')
self.logger.error(u"{0:=^130}".format(""))
self.logger.error(u"{0:=^130}".format(""))
self.logger.warn(u"{0:=^130}".format(""))
self.logger.warn(u"{0:=^130}".format(""))
self.logger.warn(u'Major Problem: Please Disable Plugin. Now Sleeping. Please contact Developer.')
self.logger.warn(u"{0:=^130}".format(""))
self.logger.warn(u"{0:=^130}".format(""))
if plugin.isEnabled():
# Can't disabled
# Can Sleep Forever Though
Expand Down Expand Up @@ -620,10 +620,10 @@ def playSound(self, action):

devicetargets = self.appleAPI.devices
for devices in devicetargets:
# self.logger.error(str(devices))
# self.logger.error(devices['id'])
# self.logger.error(devices.status())
# self.logger.error(devices.location())
# self.logger.warn(str(devices))
# self.logger.warn(devices['id'])
# self.logger.warn(devices.status())
# self.logger.warn(devices.location())
if str(targetDevice) == str(devices['id']):
devices.play_sound(subject=targetSubject)

Expand All @@ -646,10 +646,10 @@ def displayMessage(self, action):

devicetargets = self.appleAPI.devices
for devices in devicetargets:
# self.logger.error(str(devices))
# self.logger.error(devices['id'])
# self.logger.error(devices.status())
# self.logger.error(devices.location())
# self.logger.warn(str(devices))
# self.logger.warn(devices['id'])
# self.logger.warn(devices.status())
# self.logger.warn(devices.location())
if str(targetDevice) == str(devices['id']):
devices.display_message(subject=targetSubject, message=targetMessage, sounds=soundenabled)

Expand Down Expand Up @@ -915,13 +915,14 @@ def refreshData(self):
if self.debugicloud:
self.logger.debug(u'targetDevice of Device equals:' + str(targetFriend))
devicetargets = self.appleAPI.devices
for devices in devicetargets:
#self.logger.error(str(devices))
#self.logger.error(devices['id'])
#self.logger.error(devices.status())
#self.logger.error(devices.location())
if str(targetFriend) == str(devices['id']):
self.refreshDataforMyDevice( dev, devices)
if devicetargets != None:
for devices in devicetargets:
#self.logger.warn(str(devices))
#self.logger.warn(devices['id'])
#self.logger.warn(devices.status())
#self.logger.warn(devices.location())
if str(targetFriend) == str(devices['id']):
self.refreshDataforMyDevice( dev, devices)

#elf.logger.error("**:"+str(targetdevice))

Expand All @@ -947,8 +948,9 @@ def refreshData(self):
self.logger.debug(e)
return

except PyiCloudFailedLoginException:
except PyiCloudFailedLoginException as e:
self.logger.debug(u'Login failed - Check username/password combination')
self.logger.debug(f"Exception message: {e}")
self.logger.debug(f"Secure Remote Password Login Failed. If first attempt delete account in PluginConfig and try again.")
return

Expand Down Expand Up @@ -1025,14 +1027,14 @@ def checkGeofence(self):

for dev in itertools.chain(indigo.devices.iter("self.FindFriendsFriend"), indigo.devices.iter("self.myDevice")):
#add online check here
#self.logger.error(f"{dev.name}")
#self.logger.warn(f"{dev.name}")
if dev.enabled and dev.states['deviceIsOnline'] == True:
self.logger.debug('Geo Details on check:' + str(igeoName) + ' For Friend:' + str(dev.name))
iDevLatitude = float(dev.states['latitude'])
iDevLongitude = float(dev.states['longitude'])
iDevUniqueName = dev.pluginProps['friendName']
iDevAccuracy = float(dev.states['horizontalAccuracy'])
#self.logger.error(str(iDevUniqueName))
#self.logger.warn(str(iDevUniqueName))
# Now check the distance for each device
# Calculate the distance
self.logger.debug('Point 1' + ' ' + str(igeoLat) + ',' + str(igeoLong) + ' Point 2 ' + str(iDevLatitude) + ',' + str(iDevLongitude))
Expand Down Expand Up @@ -1255,8 +1257,8 @@ def getLatLong(self, valuesDict=None, typeId="", dev=0):
iurl="http://www.latlong.net"
self.browserOpen(iurl)
except:
self.logger.error(u'Default web browser did not open - check Mac set up')
self.logger.error(u'or issues contacting the www.latlong.net site. Is internet working?')
self.logger.warn(u'Default web browser did not open - check Mac set up')
self.logger.warn(u'or issues contacting the www.latlong.net site. Is internet working?')
return

def refreshDataforMyDevice(self,dev, appleDevice):
Expand All @@ -1265,10 +1267,10 @@ def refreshDataforMyDevice(self,dev, appleDevice):
if self.debugicloud:
self.logger.debug(str('Now updating Data for : ' + str(dev.name) + ' with data received: '))

# self.logger.error(str(devices))
# self.logger.error(devices['id'])
# self.logger.error(devices.status())
# self.logger.error(devices.location())
# self.logger.warn(str(devices))
# self.logger.warn(devices['id'])
# self.logger.warn(devices.status())
# self.logger.warn(devices.location())

if appleDevice is None:
self.logger.debug(u'No data received for device:' + str(
Expand Down Expand Up @@ -1449,7 +1451,7 @@ def refreshDataForDev(self, dev, follow):
if follow is not None:
if 'location' in follow:
if follow['location'] is not None:
#self.logger.error(f"{follow['location']}")
#self.logger.warn(f"{follow['location']}")
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'])
Expand Down Expand Up @@ -1882,24 +1884,24 @@ def iAuthorise(self, iUsername, iPassword):
return 0, self.appleAPI

except PyiCloudFailedLoginException:
self.logger.error(u'Login failed - Check username/password - has it changed recently?. ')
self.logger.warn(u'Login failed - Check username/password - has it changed recently?. ')
self.appleAPI = None
self.allDevicesOffline()
return 1, 'NL'

except PyiCloud2SARequiredException:
self.logger.error(u'Login failed. Account requires 2nd factor, verification code setup. Please see config window')
self.logger.warn(u'Login failed. Account requires 2nd factor, verification code setup. Please see config window')
self.requires2FA = True
self.appleAPI = None
self.allDevicesOffline()
self.triggerCheck2fa()
return 1, 'NL'

except ValueError as e:
self.logger.error(u"{0:=^130}".format(""))
self.logger.error(u'Login failed - 2FA Authenication is supported. ')
self.logger.warn(u"{0:=^130}".format(""))
self.logger.warn(u'Login failed - 2FA Authenication is supported. ')
self.logger.debug(u'Error Given is:'+str(e)+str(e.__dict__))
self.logger.error(u"{0:=^130}".format(""))
self.logger.warn(u"{0:=^130}".format(""))
self.allDevicesOffline()
return 1, 'NL'

Expand Down Expand Up @@ -1964,30 +1966,30 @@ def loginAccount(self, valuesDict):
self.logger.debug(u"Using Details: Username:"+str(valuesDict['appleId'])+u" and password:"+str(valuesDict['applePwd']))
self.appleAPI = None
self.pluginPrefs['appleAPIid']= ""
self.logger.info(u"{0:=^130}".format(""))
self.logger.info(u'Attempting Login to Apple Account:'+str(valuesDict['appleId']))
#self.logger.info(u"{0:=^130}".format(""))
self.logger.info(u'Attempting Login to Apple Account: '+str(valuesDict['appleId']))


valuesDict['appleAPIid']=''
iLogin = self.iAuthorise(valuesDict['appleId'], valuesDict['applePwd'])
if self.appleAPI != None:
#self.logger.info(u"Account username and password has been verifed by Apple")
self.logger.debug(u"Account Requires 2FA to continue = "+str(self.appleAPI.requires_2fa))
self.logger.info(u"{0:=^130}".format(""))
#self.logger.info(u"{0:=^130}".format(""))
self.requires2FA = self.appleAPI.requires_2fa
return valuesDict

def submitCode(self,valuesDict):
self.logger.debug(u'submit Code Button pressed Called.')
vercode = valuesDict['verficationcode']
if vercode is None:
self.logger.error("Please enter code")
self.logger.warn("Please enter code")
return

validcode = self.appleAPI.validate_2fa_code(vercode)

if validcode == False:
self.logger.error("Code Error: Please try again...")
self.logger.warn("Code Error: Please try again...")
return
else:
self.logger.info("Verification Code Accepted.")
Expand Down Expand Up @@ -2489,7 +2491,7 @@ def triggerCheck2fa(self):
self.logger.debug("Checking trigger as 2FA state called")
for triggerId, trigger in sorted(self.triggers.items()):
self.logger.debug("Checking Trigger (%s), Type: %s, Friend: %s" % (trigger.name, trigger.id, trigger.pluginTypeId))
# self.logger.error(str(trigger))
# self.logger.warn(str(trigger))
if trigger.pluginTypeId == "account2FAneeded" :
# 2fa failed
# send trigger.
Expand Down Expand Up @@ -2517,7 +2519,7 @@ def triggerCheck(self, device, friend, triggertype):
for triggerId, trigger in sorted(self.triggers.items()):

self.logger.debug("Checking Trigger %s (%s), Type: %s, Friend: %s, and event : %s" % (trigger.name, trigger.id, trigger.pluginTypeId, friend, triggertype))
#self.logger.error(str(trigger))
#self.logger.warn(str(trigger))

if trigger.pluginTypeId =='account2FAneeded': ## selected a 2FA triggertype
if triggertype=='account2FAneeded':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def __init__(
with open(self.session_path) as session_f:
self.session_data = json.load(session_f)
except: # pylint: disable=bare-except
LOGGER.info("Session file does not exist")
LOGGER.info("No saved Session details exists, starting afresh.")

if not path.exists(self._session_directory):
mkdir(self._session_directory)
Expand Down Expand Up @@ -542,8 +542,8 @@ def encode(self):
headers=headers,
)
except PyiCloudAPIResponseException as error:
LOGGER.exception("Complete failed")
msg = "Invalid email/password combination."
LOGGER.debug("Complete failed")
msg = "Invalid username/password combination."
raise PyiCloudFailedLoginException(msg, error) from error

complete_resp_data = complete_resp.json()
Expand All @@ -567,7 +567,9 @@ def encode(self):
self._webservices = self.data["webservices"]
LOGGER.debug("Authentication completed successfully")
else:
raise Exception("Authentication failed")
LOGGER.info("Login was not successful. Please check username and password combination.")
LOGGER.info("If recent changes, consider deleting plugin acccount via delete button at bottom of plugin Config Page and trying again")
raise PyiCloudFailedLoginException("Login was not successful.", "Error.")

##
def _authenticate_with_credentials_service(self, service: str) -> None:
Expand Down

0 comments on commit 0020972

Please sign in to comment.