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
546 stars 54 forks source link

Remove utf-8 characters in sensor attributes #295

Closed bakerkj closed 7 months ago

bakerkj commented 10 months ago

In sensor.device_name_altitude it includes the following attributes: » mi - location 1: 12.61138 » mi - location 2: 15.8523 » mi - location 3: 31.98394

This includes the U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK character (»)

This breaks the the home assistant graphite integration (https://github.com/home-assistant/core/issues/103083).

Would it be possible to replace these unicode characters with an ascii character?

gcobb321 commented 9 months ago

I've changed the utf-8 characters to ascii characters. unzip the sensor.xip file to the icloud3directory and restart HA. Let me know how it works.

sensor.zip

bakerkj commented 9 months ago

Will do. Thank you!

bakerkj commented 9 months ago

@gcobb321 it looks like in addition to the fix for utf-8 -> ascii there changes in sensor.py that depend on changes in other files that I don't have. Here is the traceback.

Thanks!

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 215, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 816, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/icloud3/__init__.py", line 42, in <module>
    from .                              import config_flow
  File "/config/custom_components/icloud3/config_flow.py", line 70, in <module>
    from .                  import sensor as ic3_sensor
  File "/config/custom_components/icloud3/sensor.py", line 43, in <module>
    from .helpers.time_util import (time_to_12hrtime, time_remove_am_pm, secs_to_time_str, mins_to_time_str,
ImportError: cannot import name 'adjust_time_hour_value' from 'custom_components.icloud3.helpers.time_util' (/config/custom_components/icloud3/helpers/time_util.py)
gcobb321 commented 9 months ago

I’ll send you the complete rc9, which hasn’t been released yet, Friday morning

gcobb321 commented 9 months ago

Unzip icloud3_v3-rc9.zip into the icloud3 directory and restart HA.

There are a lot of updates, bug fixes and new features. Review ChangeLog.txt for a complete list. They are at the top under the rc9 heading.

icloud3_v3-rc9.zip

bakerkj commented 9 months ago

@gcobb321 this looks good. Thank you!

bakerkj commented 7 months ago

I think we can close this out.