gcobb321 / icloud3_v3

iCloud3 v3, Development Version - This Repo/Version is used for development and testing of new and updated features. It is not the official release of iCloud3 v3, .
MIT License
169 stars 13 forks source link

I encountered an error when entering the verification code in Home Assistant 2023.8.3 #194

Closed jhchenchong closed 1 year ago

jhchenchong commented 1 year ago

截屏2023-09-03 10 29 19

gcobb321 commented 1 year ago

Are you in China. If so, Apple has a different location server address. You may need to edit the iCloud3 configuration file.

File: /config/.storage/icloud3/``` configuration

"data": { "tracking": { "username": "your username", "password": "your encoded password", "encode_password": true, "icloud_server_endpoint_suffix": "cn",

     ….,

Change `icloud_server_endpoint_suffix` parameter to add `cn`. Do not change the other parameters. Then restart HA. 

Let me know if this works and I will add a configuration parameter for this. There is a check to see what the country code is when iCloud3 starts to try to do this automatically. Please send the iCloud3 Log file `/config/icloud3-0.log` to geekstergary@gmail.com so I can check this out after you restart HA. 
jhchenchong commented 1 year ago

Yes, I am in China. I followed your instructions and modified the configuration, but unfortunately, it did not work and the error is still the same.

https://github.com/gcobb321/icloud3_v3/assets/19201316/2ef8328d-649e-41aa-894b-f57b7b3f9ad9

jhchenchong commented 1 year ago

I tried to debug to see what happened, but it seems that it cannot run on the latest development version. 截屏2023-09-03 22 01 53

gcobb321 commented 1 year ago

I will need the `/config/icloud3-0.log, file to see the cause of the error.

  1. Turn on Debug log level —> Configure Settings > Page 2 > Format Parameters > Log Level > Debug auto restart
  2. Restart HA and create error
  3. Send the file to geekstergary@gmail.com or post it to GitHub. If you post it, I’ll delete it when I get the info I need.

I get the country code from HA. If it is cn, .cn is added to the the Apple iCloud web site address end point. I want to see if the verification code entry is failing because the web site is wrong.

gcobb321 commented 1 year ago

TRY THIS FIRST BEFORE DOING THE ABOVE

Edit ‘/config/icloud3/support/pyicloud_ic3.py’. Change line 403 to: AUTH_ENDPOINT = f"https://idmsa.apple.com/appleauth/auth{url_suffix}"

Lines 401 and 402 have the url_suffix. Line 403 does not.

Save the file and restart HA. Then retry the verification code entry.

jhchenchong commented 1 year ago

2023-09-04 00:07:02 [init....:0136] iCloud3 v3.0pr1, Log File: 2023-09-04 00:07:02 2023-09-04 00:07:03 [init....:0136] Profile: {'version': 1, 'ic3_version': '3.0pr1', 'version_install_date': '2023-09-03 10:53:18', 'config_update_date': '2023-09-04 00:07:02', 'event_log_card_directory': 'www/icloud3', 'event_log_card_program': 'icloud3-event-log-card.js', 'event_log_btnconfig_url': '', 'event_log_version_running': '', 'event_log_version': ''} 2023-09-04 00:07:03 [init....:0136] General Configuration: {'log_level': 'debug-auto-reset', 'unit_of_measurement': 'mi', 'time_format': '12-hour', 'display_zone_format': 'fname', 'device_tracker_state_source': 'ic3_fname', 'max_interval': 240, 'offline_interval': 20, 'exit_zone_interval': 3, 'iosapp_alive_interval': 60, 'old_location_threshold': 3, 'old_location_adjustment': 0, 'gps_accuracy_threshold': 100, 'display_gps_lat_long': True, 'travel_time_factor': 0.6, 'tfz_tracking_max_distance': 8, 'passthru_zone_time': 0.5, 'track_from_base_zone': 'home', 'track_from_home_zone': True, 'center_in_zone': False, 'discard_poor_gps_inzone': False, 'distance_between_devices': True, 'inzone_intervals': {'iphone': 120, 'ipad': 120, 'watch': 15, 'airpods': 15, 'no_iosapp': 15, 'other': 120}, 'waze_used': True, 'waze_region': 'us', 'waze_min_distance': 1, 'waze_max_distance': 1000, 'waze_realtime': False, 'waze_history_database_used': True, 'waze_history_max_distance': 20, 'waze_history_track_direction': 'north_south', 'stat_zone_fname': 'StatZon#', 'stat_zone_still_time': 8, 'stat_zone_inzone_interval': 30, 'stat_zone_base_latitude': 1, 'stat_zone_base_longitude': 0, 'display_text_as': ['#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9', '#10']} 2023-09-04 00:07:03 [init....:0136] {'country_code': 'CN', 'region_code': 'CQ', 'zip_code': None, 'region_name': 'Chongqing', 'city': 'Chongqing', 'time_zone': 'Asia/Shanghai', 'latitude': 29.5689, 'longitude': 106.5577, 'use_metric': True} 2023-09-04 00:07:03 [init....:0136]
2023-09-04 00:07:03 [init....:0136]
2023-09-04 00:07:03 [init....:0142] Setting up iCloud3 3.0pr1 - Using Integration method 2023-09-04 00:07:08 [sensor......:1169] Sensor entity created: sensor.icloud3_event_log, #1 2023-09-04 00:07:08 [sensor......:1169] Sensor entity created: sensor.icloud3_wazehist_track, #2 2023-09-04 00:07:08 [sensor......:0113] Sensor entities created: 2 2023-09-04 00:07:08 [sensor......:0114] Sensor entities excluded: 0 2023-09-04 00:07:09 [waze........:0066] Set Up Waze > Server-United States, Canada (US), CountryCode-US, MinDist-1km, MaxDist-1000km, Realtime-False, HistoryDatabaseUsed-True 2023-09-04 00:07:09 [waze_history:0177] > Waze History Database > /config/.storage/icloud3/waze_location_history.db 2023-09-04 00:07:09 [waze_history:0497] Waze History Database > Compressed, Record Count-0 2023-09-04 00:07:09 [start_ic3...:0434] iCloud3 Alert > The username or password has not been set up, iCloud Location Services will not be used. Device tracking will be done using iOS App location data. 2023-09-04 00:07:09 [start_ic3...:0356] Configure iCloud3 Operations > • Load configuration parameters • Set Display Text As Fields (0 used) • Set Default Tracking Method (iCloud) • Initialize Debug Control (debug-auto-reset) • Set Unit of Measure Formats (mi) • Set Event Log Record Limits (1500 Events) • Device Tracker State Value Source (iCloud3 Zone Friendly Name) 2023-09-04 00:07:10 [init....:0207] START iCloud3 Initial Load Executor Job (iCloud3.start_icloud3) 2023-09-04 00:07:10 [start_ic3_co:0064] STAGE 1 > iCloud3 Directory > /config/custom_components/icloud3 2023-09-04 00:07:10 [start_ic3_co:0068] STAGE 1 > iCloud3 Configuration File > /config/.storage/icloud3/configuration 2023-09-04 00:07:10 [start_ic3...:0726] STAGE 1 > iCloud3 Event Log > • Current Version Installed-v3.0.15 • File-/config/www/icloud3/icloud3-event-log-card.js 2023-09-04 00:07:10 [start_ic3_co:0074] STAGE 1 > LocationInfo-{'country_code': 'CN', 'region_code': 'CQ', 'zip_code': None, 'region_name': 'Chongqing', 'city': 'Chongqing', 'time_zone': 'Asia/Shanghai', 'latitude': 29.5689, 'longitude': 106.5577, 'use_metric': True} 2023-09-04 00:07:10 [time_util...:0480] STAGE 1 > Local Time Zone Offset > UTC+08:00 hrs, CST, Country Code-US 2023-09-04 00:07:10 [start_ic3_co:0079] STAGE 1 > Stage 1 > Initial Preparations 2023-09-04 00:07:10 [start_ic3...:0957] STAGE 2 > Set up Zones > zone, Display (fname) • home, 我的家 (r100m) 2023-09-04 00:07:10 [start_ic3...:0982] STAGE 2 > Special Zone Setup > • PassThru Zone > Delay-30 secs • Stationary Zone > Radius-200m, DistMoveLimit-125m, MinDistFromAnotherZone-200m, BaseDistFromHome-996m, BaseLocation-(29.44761, 106.43636) 2023-09-04 00:07:10 [waze........:0066] STAGE 2 > Set Up Waze > Server-United States, Canada (US), CountryCode-US, MinDist-1km, MaxDist-1000km, Realtime-False, HistoryDatabaseUsed-True 2023-09-04 00:07:10 [waze_history:0177] STAGE 2 > > Waze History Database > /config/.storage/icloud3/waze_location_history.db 2023-09-04 00:07:11 [waze_history:0497] STAGE 2 > Waze History Database > Compressed, Record Count-0 2023-09-04 00:07:11 [start_ic3_co:0107] STAGE 2 > Stage 2 > Prepare Support Services 2023-09-04 00:07:11 [start_ic3_co:0131] STAGE 2 > CONFIGURATION ALERT > DEVICES MUST BE SET UP TO ENABLE TRACKING

                                                   1. Select `Settings > Devices & Services > Integrations`
                                                   2. Select `+Add Integration` to add the iCloud3 integration if it is not dislayed. Then search for `iCloud3`, select it and complete the installation.
                                                   3. Select `iCloud3 > Configuration` to open the iCloud3 Configuration Wizard
                                                   4. Review and setup the `iCloud Account` and `iCloud3 Devices` configuration windows 
                                                   5. Exit the configurator and `Restart iCloud3`

2023-09-04 00:07:11 [start_ic3_co:0166] STAGE 3 > Stage 3 > Prepare Configured Devices 2023-09-04 00:07:11 [start_ic3_co:0184] STAGE 4 > CONFIGURATION ALERT > The iCloud username or password has not been set up or is incorrect. iCloud will not be used for location tracking 2023-09-04 00:07:11 [start_ic3...:1804] STAGE 4 > iOS App Devices > 0 of 0 iCloud3 Devices Configured • iPhone (iphone) → Not Monitored, iPhone (iPhone14,7) 2023-09-04 00:07:11 [start_ic3_co:0224] STAGE 4 > Stage 4 > Setup iCloud & iOSApp Data Source 2023-09-04 00:07:11 [start_ic3...:1983] STAGE 5 > iCloud Location Tracking is not available 2023-09-04 00:07:11 [start_ic3_co:0294] STAGE 5 > Stage 5 > Tracked Devices Configuration Summary 2023-09-04 00:07:11 [start_ic3...:2025] STAGE 6 > StatZones- 2023-09-04 00:07:11 [start_ic3...:2028] STAGE 6 > Devices- 2023-09-04 00:07:11 [start_ic3...:2036] STAGE 6 > Zones-not_home, Not_Home, not_set, Not_Set, stationary, Stationary, unknown, home 2023-09-04 00:07:11 [start_ic3_co:0324] STAGE 6 > The following issues were detected when starting iCloud3. Scroll through the Startup Log for more information: • iCloud3 Integration not set up • iCloud username/password not set up or incorrect 2023-09-04 00:07:11 [icloud3_main:0170] STAGE 6 > Commit Log File Records, RequestedBy-iCloud3 Initialization

gcobb321 commented 1 year ago

I didn’t see any error messages in the above Log.

  1. Did you make the code change before the log? If not, do that and restart HA.
  2. Go through the process in the video (enter username and password) you will get verification code needed like before. So not go directly to the Enter Code screws. Select Save first, then go to it. The config did indicate the username/password were not entered and I’ll check to see it the code saves them before going to the Enter Code screen.
  3. So save before going to that screen.
jhchenchong commented 1 year ago

I have modified the code according to your instructions.

  1. I set "icloud_server_endpoint_suffix" to "cn" in "/config/.storage/icloud3/configuration"
  2. modified line 403 of "/config/icloud3/support/pyicloud_ic3.py" to "AUTH_ENDPOINT = f"https://idmsa.apple.com/appleauth/auth{url_suffix}".
  3. Then I restarted Home Assistant.

When I selected "save" and clicked on submit, I received a verification code from Apple. However, the page still showed "iCloud Account Login Failed, Invalid Username or Password" and did not redirect to another page.

截屏2023-09-04 09 11 35
gcobb321 commented 1 year ago

The LOGIN line indicates you are logged into username-72……., password-Cc…….. Look in the configuration file and verify the username and password were saved
By selecting Save, then Submit, it would update the config file and not change screens. Now select Enter/Request code and Submitted. That will display the Code entry screen. You can also display the screen from the Menu. You may have to request a code again and then enter it.

The error message may be wrong.

jhchenchong commented 1 year ago

I found that the value set for "icloud_server_endpoint_suffix" did not work, so I uncommented line 398 in "pyicloud_ic3.py". It seems to work now. Also, I realized that "AUTH_ENDPOINT" does not need "url_suffix". So, all I did was to uncomment line 398 in "pyicloud_ic3.py". Thanks a lot. This is an excellent custom integration. 截屏2023-09-04 11 14 02