Giter Site home page Giter Site logo

ha-entity-tz's People

Contributors

pnbruckner avatar

Stargazers

 avatar

Watchers

 avatar

ha-entity-tz's Issues

RuntimeWarning: overflow encountered in scalar multiply

found this during testing beta HA 2024.5. with asyncio debug mode

Deze fout is ontstaan door een aangepaste integratie.

Logger: py.warnings
Bron: custom_components/entity_tz/helpers.py:90
integratie: Tijdzone van entiteit (documentatie, problemen)
Eerst voorgekomen: 08:24:31 (1 gebeurtenissen)
Laatst gelogd: 08:24:31

/usr/local/lib/python3.12/site-packages/timezonefinder/helpers.py:79: RuntimeWarning: overflow encountered in scalar multiply and (int64(y2) - int64(y)) * (int64(x2) - int64(x1))

Handle timezonefinder exception

This sometimes happens:

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/entity_tz/helpers.py:83
integration: Entity Time Zone (documentation, issues)
First occurred: March 17, 2024 at 11:31:54 AM (2 occurrences)
Last logged: 7:57:54 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/entity_tz/__init__.py", line 102, in update_from_entity
    entity_tz = await get_tz(hass, new_state)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/entity_tz/helpers.py", line 98, in get_tz
    tz = await hass.async_add_executor_job(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/entity_tz/helpers.py", line 83, in _get_tz_from_loc
    if (tz_name := tzf.timezone_at(lat=lat, lng=lng)) is None:
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/timezonefinder/timezonefinder.py", line 677, in timezone_at
    ids = self.id_list(possible_polygons, nr_possible_polygons)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/timezonefinder/timezonefinder.py", line 435, in id_list
    zone_id = self.id_of(polygon_id)
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/timezonefinder/timezonefinder.py", line 274, in id_of
    return unpack(DTYPE_FORMAT_H, poly_zone_ids.read(NR_BYTES_H))[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 2 bytes

discussion: binaries reversed?

Since you dont have Discussion enabled in the repo, please allow me here to open this discussion:

Working with your new integration for some time now, and it all works very nicely. thanks again for creating it in the first place.

There is 1 thing that I find myself doing, and it is keeping me from doing my former template sensors away.

In all of my logic, I test on being in the local time(zone) or being in homeland....

So, the reversed of what the current binary sensor entities test.
I was wondering what you would think of reversing the logic to a more positive pov.

in_local_timezone
in_home_country

or adding these ofc, to suit both needs

Scherm­afbeelding 2024-01-30 om 22 00 44

ofc, these templates are ok, but since we now have a dedicated integration doing the works for us, I figured it might be an interesting evolution to add this

b7 new geopy entities cause timeout error

Please see below.
Also noticed a startup timeout, and a spontaneous restart. I am not 100% certain entity-tz caused this, but it occurred after having installed the new beta, and the instance got unresponsive during its first restart.
Dont see those spontaneous restarts often, hardly ever tbh, so I link to to this for now.
Might be caused by the same timeout error?

Deze fout is ontstaan door een aangepaste integratie.

Logger: homeassistant
Source: custom_components/entity_tz/helpers.py:142
Integration: Tijdzone van entiteit (documentation, issues)
First occurred: 11:00:03 (1 occurrences)
Last logged: 11:00:03

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/geopy/adapters.py", line 587, in _normalize_exceptions
    yield
  File "/usr/local/lib/python3.11/site-packages/geopy/adapters.py", line 544, in get_json
    async with self._request(url, timeout=timeout, headers=headers) as resp:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1187, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 500, in _request
    with timer:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/helpers.py", line 735, in __exit__
    raise asyncio.TimeoutError from None
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/entity_tz/__init__.py", line 56, in update_from_entity
    await get_location(hass, new_state),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/entity_tz/helpers.py", line 142, in get_location
    location = await etz_data(hass).nominatim.reverse(coordinates)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/geopy/geocoders/base.py", line 374, in fut
    res = callback(await result)
                   ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/geopy/adapters.py", line 543, in get_json
    with self._normalize_exceptions():
  File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/geopy/adapters.py", line 593, in _normalize_exceptions
    raise GeocoderTimedOut("Service timed out")
geopy.exc.GeocoderTimedOut: Service timed out

as a result of which all entities, so not only the new country and address entities go 'unknown':

Scherm­afbeelding 2023-12-16 om 11 01 49

FR: add "import_executor": true to manifest

please see https://discord.com/channels/330944238910963714/427516175237382144/1212682202433716264

moving possible event loop blocking components BDraco suggests adding the above line to the manifest file.

see: https://github.com/home-assistant/core/pull/111772/files#diff-bf8da1d2c4d5a69bf051bd6087b795bdf1313b0b8fddbaae567814d271bb8256R21

I didnt yet test it locally, as I am not sure it would be the only thing required for it to be functional.

Please have a look?

another suggestion by Nick is:

instead of yield I think the work could be done in the executor https://github.com/pnbruckner/ha-entity-tz/pull/5/files
no more event loop blocking

I copied this without understanding it, so hope you do....
thanks

long setup times (possibly causing other timing related problems.)

running debugpy because BDraco asked me while we were trying to find the root cause of some severe timing loggings, we noticed these:

2024-02-12 18:04:13.813 WARNING (MainThread) [asyncio] Executing <Task pending name='setup component entity_tz' coro=<_async_setup_component() running at /usr/src/homeassistant/homeassistant/setup.py:366> cb=[set.remove(), Task.task_wakeup()] created at /usr/src/homeassistant/homeassistant/core.py:633> took 8.793 seconds

2024-02-12 18:05:18.088 WARNING (MainThread) [asyncio] Executing <Handle init_etz_data.<locals>.update_zones(<Event core_config_updated[L]>) at /config/custom_components/entity_tz/helpers.py:110 created at /usr/src/homeassistant/homeassistant/core.py:601> took 8.867 seconds

I seem to recall when you started this new integration, you mentioned downloading an external library, or expected it to be available already because HA uses it also.

Not sure anymore, but please have a look if this could be improved?

thanks,
Marius

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.