* YAML loader performance improvements
- Cache the name of the loader since we call it multiple
times for every line
- Add a fast path for scalar tags since they are the
most common
* Update homeassistant/util/yaml/loader.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
* remove unreachable code
---------
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
* Add volume flow rate conversions
* Add missing translations
* Adjust liter unit and add gallons per minute
* Adjust to min instead of m for minutes
* Add matching class for number
* Add some tests for number and sensor platform
* Add deprecated constants
* Add explicit list of flow rate for check
This reverts commit 105171af31.
* Signficantly reduce executor contention during bootstrap
At startup we have a thundering herd wanting to use the executor
to load manifiest.json. Since we know which integrations we are
about to load in each resolver step, group the manifest loads
into single executor jobs by calling async_get_integrations on
the deps of the integrations after they are resolved.
In practice this reduced the number of executor jobs
by 80% during bootstrap
* merge
* naming
* tweak
* tweak
* not enough contention to be worth it there
* refactor to avoid waiting
* refactor to avoid waiting
* tweaks
* tweaks
* tweak
* background is fine
* comment
* Enable strict typing of date_time
* Fix parse_datetime
* Add test
* Add comments
* Update tests/util/test_dt.py
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
---------
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
Reduce overhead connect dispatcher
- We tend to have 1000s (or 10000s) of connected dispatchers which
makes these prime targets to reduce overhead/memory
- Instead of creating new functions to wrap log exceptions each time
use partials which reuses the function body and only create new
arguments
Previous optimizations #103307#93602
* Add color temperature to the color mode fallbacks
* Manually add ATTR_COLOR_TEMP since ATTR_COLOR_TEMP_KELVIN is pre-parsed
* Include the legacy ATTR_COLOR_TEMP attribute in the tests
* Apply suggestions from code review
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Add citation for McCamy's approximation formula
If still existing, also see page 3 of https://www.st.com/resource/en/application_note/an5638-how-correlated-color-temperature-is-calculated-by-vd6283-stmicroelectronics.pdf
* Update homeassistant/util/color.py
---------
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Language codes for Hebrew
There is 2 optional code for Hebrew:
he-IL is the new code
iw-IL is the old code , the google cloud STT for example is using the old code (iw)
* Update language.py
* Update test_language.py
* Update test_language.py
* Update test_language.py
* Simplify duplicate language check
---------
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
In #90191 we use the same ssl context for httpx now to avoid
a memory leak, but httpx previously allowed sslv2/sslv3 for
unverified connections
This reverts to the behavior before #90191
* Add language util
* Add no match tests
* Update tests/util/test_language.py
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
---------
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Use ulid-transform for constructing ulids
A future PR will use the new library to reduce the storage
overhead of ulids in the database
* tweak
* tweak
* bump
pkg_resources is abandoned and we need to move away
from using it https://github.com/pypa/pkg_resources
In the mean time we need to keep it working. This fixes
a new exception in py3.11 when a module is not installed
which allows proper fallback to pkg_resources.Requirement.parse
when needed
```
2023-02-25 15:46:21.101 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/http/view.py", line 146, in handle
result = await result
^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/config/config_entries.py", line 148, in post
return await super().post(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/helpers/data_entry_flow.py", line 71, in post
result = await self._flow_mgr.async_init(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 826, in async_init
flow, result = await task
^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 844, in _async_init
flow = await self.async_create_flow(handler, context=context, data=data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 950, in async_create_flow
await async_process_deps_reqs(self.hass, self._hass_config, integration)
File "/Users/bdraco/home-assistant/homeassistant/setup.py", line 384, in async_process_deps_reqs
await requirements.async_get_integration_with_requirements(
File "/Users/bdraco/home-assistant/homeassistant/requirements.py", line 52, in async_get_integration_with_requirements
return await manager.async_get_integration_with_requirements(domain)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/requirements.py", line 171, in async_get_integration_with_requirements
await self._async_process_integration(integration, done)
File "/Users/bdraco/home-assistant/homeassistant/requirements.py", line 186, in _async_process_integration
await self.async_process_requirements(
File "/Users/bdraco/home-assistant/homeassistant/requirements.py", line 252, in async_process_requirements
await self._async_process_requirements(name, missing)
File "/Users/bdraco/home-assistant/homeassistant/requirements.py", line 284, in _async_process_requirements
installed, failures = await self.hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/requirements.py", line 113, in _install_requirements_if_missing
if pkg_util.is_installed(req) or _install_with_retry(req, kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/util/package.py", line 40, in is_installed
pkg_resources.get_distribution(package)
File "/opt/homebrew/lib/python3.11/site-packages/pkg_resources/__init__.py", line 478, in get_distribution
dist = get_provider(dist)
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/pkg_resources/__init__.py", line 354, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
``
* Optimize fetching statistics
* speed up
* avoid double groupby
* avoid another loop
* tweak flow
* fixes
* tweak
* avoid a new dt object in the cache for week/month
* avoid a new dt object in the cache for week/month
* Add Mega joule
* Reorder valid energy types
Alphabetical
* Add Mega Joule
* Add Mega Joule as valid energy unit
* Add Mega Joule
* Add Mega Joule as a Unit of Measurement to Energy
* Update tests
* Update tests
* Update number docstring
Co-authored-by: Roving Ronin <108674933+Roving-Ronin@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Prevent use of deprecated units
* Adjust obsolete util
* More units
* Add FREQUENCY
* Adjust pylint ignore
* Add ELECTRIC (current/potential)
* Add TIME
* Adjust units
* Add GJ as supported unit for energy sensors
* Update homeassistant/const.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>