pnbruckner / ha-entity-tz Goto Github PK
View Code? Open in Web Editor NEWHome Assistant Entity Time Zone Sensor
License: The Unlicense
Home Assistant Entity Time Zone Sensor
License: The Unlicense
Nominatim provides "broken down" address details in the raw.address
attribute. Optionally add a sensor attribute, or attributes, that contain some or all of this information.
E.g., let user specify a list of details desired, and then if any of those exist in raw.address
, add those as one or more attributes to the sensor entity.
Ref:
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))
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
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
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
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':
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.
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.