gcobb321 / icloud3

iCloud3 v3 - iCloud3 is an advanced iDevice tracker that uses Apple iCloud account and HA Companion App data for presence detection and location based automations.
MIT License
545 stars 54 forks source link

iCloud3 v3.0.1 (3/20/2024) has been released #322

Closed gcobb321 closed 2 months ago

gcobb321 commented 6 months ago

Go to the Releases page, download the zip file, unzip it into the icloud3 directory, restart HA and enjoy. --or-- Get it from HACS

josefelixh commented 6 months ago

Thank you for iCloud3, I like it a lot and always try to keep up to date with it. This time tried to upgrade via HACS, and getting the below error right after restart, was running v3.0.rc10.4. Re-downloading the previous version fixes the issue.

See below the entry in homeassistant logs, the integration doesn't seem to write anything in icloud3-0.log

Logger: homeassistant.setup Source: setup.py:390 First occurred: 18:01:14 (1 occurrences) Last logged: 18:01:14

Error during setup of component icloud3 Traceback (most recent call last): File "/config/custom_components/icloud3/init.py", line 66, in async_setup if tracker['platform'] == DOMAIN:


TypeError: string indices must be integers, not 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 390, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/icloud3/__init__.py", line 79, in async_setup
    log_exception(err)
  File "/config/custom_components/icloud3/helpers/messaging.py", line 422, in log_exception
    write_ic3_log_recd(traceback.format_exc())
  File "/config/custom_components/icloud3/helpers/messaging.py", line 284, in write_ic3_log_recd
    Gb.iC3Logger.info(log_msg)
    ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'info'
gcobb321 commented 6 months ago

This error was being generated when starting iCloud3 and a check was being done to see if there was an old v2 version of iCloud3 in the HA configuration.yaml file. During the check, an error was generated which then generated another error trying to add a record to the 'icloud3_0.log' file, which had not been set up yet.

None of this needed to be done and it should not effect starting iCloud3 or tracking and devices.

I have made a change to prevent this from occurring. Unzip the init.zip file into the icloud3 directory and restart HA. init.zip

gcobb321 commented 6 months ago

@josefelixh Let me know if the init.py solves your problem. If it does, I’ll promote it as an updated release

EDIT 5/22 5:54p EDT: The icloud3-0.log file is being controlled by the HA logger. See if you have the following in your configuration.yaml file. If not, add them and restart HA

logger:
  info
josefelixh commented 6 months ago

Let me know if the init.py solves your problem. If it does, I’ll promote it as an updated release

It did solve the issue, thank you very much, really appreciated!

A little question, where are the logs now? the integration doesn't seem to log anything in icloud3-0.log or home-assistant.log

DPStaude commented 6 months ago

Hello, after installation of v3.0.1 over release candidate system hangs up with two errors: Setup failed for custom integration 'icloud3': Unable to import component: Exception importing custom_components.icloud3 16:55:08 – (FEHLER) setup.py Unexpected exception importing component custom_components.icloud3 16:55:08 – (FEHLER) loader.py

Any idea what went wrong here? Thanks in advance

gcobb321 commented 6 months ago

I assume you downloaded it room HACS. I would do that again and then restart HA

gcobb321 commented 6 months ago

@josefelixh The icloud3-0.log file should be log file should still be in the config directory along with home-assistant.log, Is it still not being created when you restart HA?

If it's not, I also made a slight change to the module that creates it. Unzip messaging.zip into the icloud3/helpers directory and restart HA. See if that creates it. messaging.zip

josefelixh commented 6 months ago

@josefelixh The icloud3-0.log file should be log file should still be in the config directory along with home-assistant.log, Is it still not being created when you restart HA?

If it's not, I also made a slight change to the module that creates it. Unzip messaging.zip into the icloud3/helpers directory and restart HA. See if that creates it. messaging.zip

The file is there, as always has been, but nothing gets log anymore, the last line is below, which happened when I restarted homeassistant after the upgrade.

03-22 08:02:36 [start_ic3...:0424] HA Shutting Down

gcobb321 commented 6 months ago

Install the messaging.zip and d delete the log file and let’s see if it recreated. What is the log level parameter on the Format Parameters config screen? If it is not created, change it to Debug.

And are there any errors in the _home-assistant.log_file?

josefelixh commented 6 months ago

Install the messaging.zip and d delete the log file and let’s see if it recreated. What is the log level parameter on the Format Parameters config screen? If it is not created, change it to Debug.

And are there any errors in the _home-assistant.log_file?

@gcobb321 thank you.

gcobb321 commented 6 months ago

@josefelixh The default home assistant logger level is Warning. iCloud3 runs under the HA logger and writes all messages at the Info level. I have made a change to iCloud3 to set HA to logger to Info and will send it to you later this morning.

Adding the following to your HA configuration.yaml file will also set it to Info level.

logger:
  default : info
josefelixh commented 6 months ago

logger: default : info

@gcobb321 ok, the logger level made the difference, no need for the messages.py, with only the __init__.py patch, I can see logs again, but only with the chatty info level set for home assistant. I will try with setting the level only for icloud3 like

logger:
  default: warning
  logs:
    custom_components.icloud3: info

...and hopefully I can still see icloudv3 logs

gcobb321 commented 6 months ago

The HA log already defaults to Warning. That is why the icloud3 Info is not showing because the Info (internal value=20) is below Warning (internal value=30). I have a few things to try today to see if they work. If not, the HA Info level might be required.

gcobb321 commented 6 months ago

@josefelixh I've added a few parameters to the icloud3-0.log setup and made some other adjustments. This should fix the problem where the HA logger is not setup in the configuration.yaml file or it's default level is Warning.

Unzip _icloud3v3.0.1.1.zip into the icloud3 directory and restart HA. icloud3_v3.0.1.1.zip

DPStaude commented 6 months ago

I assume you downloaded it room HACS. I would do that again and then restart HA

I tried, but it didn't help. Then I renamed the folder, tried again. No way. I deinstalled, and even with that no success. Same errors.

What I didn't do is to delete the complete config. Maybe that should help? Now it says: not loaded. Is there any workaround to safe the complete config to import later?

Or should I try to go back to the latest rc to use it as it worked?

Thanks a lot in advance.

gcobb321 commented 6 months ago

@DPStaude Delete the iCloud3 integration Delete the iCloud3 directory Restart HA Restart HA again. The 2nd restart will a cache. Rename the config/.storage/icloud3 directory to something else to save the iCloud3 config Reinstall iCloud3. Instead of using HACS, install the v3.0.1.1.zip in a post a few entries above this one. Readd the iCloud3 integration Hopefully it will load. If not, create an issue and we will look at some logs and try a few other things.

josefelixh commented 6 months ago

@josefelixh I've added a few parameters to the icloud3-0.log setup and made some other adjustments. This should fix the problem where the HA logger is not setup in the configuration.yaml file or it's default level is Warning.

Unzip _icloud3v3.0.1.1.zip into the icloud3 directory and restart HA. icloud3_v3.0.1.1.zip

@gcobb321 This seems to have fixed all the issues, the integration loaded just fine and I can see logging in icloud3-0.log thank you very much. I assume you'll be pushing this version to HACS, which still showing v3.0.1, a minor thing.

Not sure if this is the right place for suggestions, but the main thing I use the logs for is to double check that when I receive and email from apple regarding an authentication on my account, is it indeed from icloudV3. It will be very helpul to have a sensor in the iCloud3 v3 Device regarding the authentications, or maybe Logbook there.

Again, thank you very much!

russellmoran99 commented 6 months ago

Thank you for v3. I have been using it for a few months, no problems. After the last update it is no longer working. Following error:

Home Assistant Core Unexpected exception importing platform custom_components.icloud3.device_tracker March 26, 2024 at 3:41:49 PM – (ERROR) loader.py - message first occurred at March 25, 2024 at 6:59:54 PM and shows up 5 times

Logger: homeassistant.loader Source: loader.py:842 First occurred: March 25, 2024 at 6:59:54 PM (5 occurrences) Last logged: March 26, 2024 at 3:41:49 PM

Unexpected exception importing platform custom_components.icloud3.device_tracker Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 842, in get_platform cache[full_name] = self._import_platform(platform_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 859, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1126, in _find_and_load_unlocked File "", line 241, in _call_with_frames_removed File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/config/custom_components/icloud3/init.py", line 31, in from .helpers.messaging import (_trace, _traceha, open_ic3_log_file_init, File "/config/custom_components/icloud3/helpers/messaging.py", line 70 TABS_BOX_DEBUG = f"{'\t'*10} " ^ SyntaxError: f-string expression part cannot include a backslash


Any help appreciated.

gcobb321 commented 6 months ago

What is really strange is the next few lines of code have the same statement and do not generate an error. And I am not having a problem on my system.

Anyway, unzip messaging.zip into the icloud3/helpers directory and restart HA. messaging.zip

russellmoran99 commented 6 months ago

What is really strange is the next few lines of code have the same statement and do not generate an error. And I am not having a problem on my system.

Anyway, unzip messaging.zip into the icloud3/helpers directory and restart HA. messaging.zip

Works now! Thanks for being so quick. I really appreciate it.