* Switch back to using call_later for the slow entity update warning
I had originally changed this to create a task and wait
in #41184 but that does not make sense anymore with newer
cpython as the profile now shows the original method is cheaper
(or I did it wrong the first time)
* fix missing block till done since there is no longer a task being created which would run the event loop once
* Fix memory churn in state templates
The LRU for state templates was limited to 512 states. As soon
as it was exaused, system performance would tank as each template
that iterated all states would have to create and GC any state
> 512
* does it scale?
* avoid copy on all
* comment
* preen
* cover
* cover
* comments
* comments
* comments
* preen
* preen
* Speed up entity filter when there are many glob matchers
Since we do no care about which glob matches we can
combine all the translated globs into a single regex
which reduces the overhead
* delete unused code
* preen
* Avoid more task creation in the discovery helper
There is no longer a reason to awaiti the jobs being dispatched
since nothing was using the result and there is no risk of
job being garbage collected prematurely anymore since
the task revamp
* Update homeassistant/helpers/discovery.py
* Allow passing an optional name to async_track_time_interval
This is the same idea as passing a name to asyncio.create_task which
makes it easier to track down bugs
* more
* short
* still cannot find it
* add a few more
* test
* Add filters to climate and light service descriptions
* Allow specifying enums directly
* Update service descriptions
* Adjust test
* Cache entity features
* Lint
* Improve error handling, add list of known base components
* Don't allow specifying an entity feature as int
* Adds a loader to enable jinja imports.
* Switch to in-memory
* Move loading custom_jinja off of the event loop
* Raise TemplateNotFound if template doesn't exist
* Fix docstring
* Adds a service to reload custom jinja
* Remove IO from test setup
* Improve coverage and small refactor
* Incorporate feedback and use .jinja extension
* Check the loaded sources in test.
* Incorporate PR feedback.
* Update homeassistant/helpers/template.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
---------
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Migrate integration_platform helper to use async_get_integrations
We were fetching integrations inside the gather one
at a time. This is inefficent.
* cleanup
* cleanup
* add task name
* small tweaks
* gather only if we have tasks
When a template render raised an exception we would start listening for
all states until the template did not raise an exception anymore. This
was not needed since the entity that is causing the exception was
already in the tracker.
Re-rendering on all state changes can be extremely expensive and can
bring an instance into a sluggish or unresponsive state when updating
from a much older version that did not raise ValueError when a default
was missing.
* Improve event filters to reject earlier
- Avoid running the callbacks for state added/removed from
a domain if there are no listeners that care about the domain
- Remove some impossible checks in the listeners that will
never match since they were already rejected by the filter
* leave one guard since there is a race when we return control via await
* Add support for multiple device classes
* Add support for entity filter selector
* Add support for device filter selector
* Apply suggestions
* Fix wrong property name
* Update snapshot
---------
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Add WS command config/entity_registry/list_for_display
* Make more keys in the display dict optional
* Move disabled_by check to ws command handler
* Hide hidden_by if not hidden
* Use send_json_auto_id in the new test
* Don't include entities which have no data needed for display
* Include platform for entries with translation_key
* Use blocking in service calls and verify result
* Block for 2 seconds and update states after
* Small timeout in service call to allow exceptions
* Move sun test
The check for identical flows only worked after
the start event. We now check against pending
flows as well
If startup took a while we could end up
with quite the thundering herd
* Add JSON type definitions
* Sample use
* Keep mutable for a follo-up PR (avoid dead code)
* Use list/dict
* Remove JsonObjectType
* Remove reference to Union
* Cleanup
* Improve rest
* Rename json_dict => json_data
* Add docstring
* Add type hint to json_loads
* Add cast
* Move type alias to json helpers
* Cleanup
* Create and use json_loads_object
* Make error more explicit and add tests
* Use JsonObjectType in conversation
* Remove quotes
* Refactor async_match_states
* Check entity name after state, before aliases
* Give entity name matches priority over area names
* Don't force result to have area
* Add area alias in tests
* Move name/area list creation back
* Clean up PR
* More clean up
* Use intent responses from home_assistant_intents
* Use error responses from home_assistant_intents
* Remove speech checks for intent tests (set by conversation now)
* Bump hassil and home-assistant-intents versions
* Use Home Assistant JSON reader when loading intents
* Remove speech checks for light tests (done in agent)
* Add more tests for code coverage
* Add test for reloading on new component
* Add test for non-default response
* Move entity/area resolution to async_match_states
* Special case for covers in HassTurnOn/Off
* Enable light color/brightness on areas
* Remove async_register from default agent
* Remove CONFIG_SCHEMA from conversation component
* Fix intent tests
* Fix light test
* Move entity/area resolution to async_match_states
* Special case for covers in HassTurnOn/Off
* Enable light color/brightness on areas
* Remove async_register from default agent
* Remove CONFIG_SCHEMA from conversation component
* Fix intent tests
* Fix light test
* Fix humidifier intent handlers
* Remove DATA_CONFIG for conversation
* Copy ServiceIntentHandler code to light
* Add proper errors to humidifier intent handlers
* Add language to conversation and intent response
* Move language to intent response instead of speech
* Extend intent response for voice MVP
* Add tests for error conditions in conversation/process
* Move intent response type data into "data" field
* Move intent response error message back to speech
* Remove "success" from intent response
* Add id to target in intent response
* target defaults to None
* Update homeassistant/helpers/intent.py
* Fix test
* Return conversation_id and multiple targets
* Clean up git mess
* Fix linting errors
* Fix more async_handle signatures
* Separate conversation_id and IntentResponse
* Add unknown error code
* Add ConversationResult
* Don't set domain on single entity
* Language is required for intent response
* Add partial_action_done
* Default language in almond agent
* Remove partial_action_done
* Fix linting
* Rename success/fail targets
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Add language to conversation and intent response
* Move language to intent response instead of speech
* Extend intent response for voice MVP
* Add tests for error conditions in conversation/process
* Move intent response type data into "data" field
* Move intent response error message back to speech
* Remove "success" from intent response
* Add id to target in intent response
* target defaults to None
* Update homeassistant/helpers/intent.py
* Fix test
* Return conversation_id and multiple targets
* Clean up git mess
* Fix linting errors
* Fix more async_handle signatures
* Separate conversation_id and IntentResponse
* Add unknown error code
* Add ConversationResult
* Don't set domain on single entity
* Language is required for intent response
* Add partial_action_done
* Default language in almond agent
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Add language to conversation and intent response
* Move language to intent response instead of speech
* Extend intent response for voice MVP
* Add tests for error conditions in conversation/process
* Move intent response type data into "data" field
* Move intent response error message back to speech
* Remove "success" from intent response
* Add id to target in intent response
* target defaults to None
* Update homeassistant/helpers/intent.py
* Fix test
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Add language to conversation and intent response
* Add language parameter to conversation/process service
* Move language to intent response instead of speech
* Add language to almond conversation agent
* Fix intent test
* Add translation_key attribute to entity state
* Update accuweather test
* Index entity translation keys by platform
* Store translation key in entity registry
* Make validate async in SchemaOptionsFlowHandler
* Adjust group
* Adjust tests
* Move all to async
* Adjust integrations
* Missed an integration
* Missed one
* Rebase to fix conflict
* Allow configuring country and language in core config
* Add script for updating list of countries
* Use black for formatting
* Fix quoting
* Move country codes to a separate file
* Address review comments
* Add generated/countries.py
* Get default language from owner account
* Remove unused variable
* Add script to generate list of supported languages
* Add tests
* Fix stale docsring
* Use format_python_namespace
* Correct async_user_store
* Improve typing
* Fix with_store decorator
* Initialize language in core store migration
* Fix startup
* Tweak
* Apply suggestions from code review
Co-authored-by: Franck Nijhof <git@frenck.dev>
* Update storage.py
Co-authored-by: Franck Nijhof <git@frenck.dev>
* Add type to template hassfunction decorator
* Adjust to use EvalContext
* Use runtime.Context
* Use TypeVar for context
* Use jinja2.runtime.Context
* Reverse declarations
* Use Any
* Update homeassistant/helpers/template.py
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
* Add OptionsFlow helper classes
* More integrations
* Adjust SchemaOptionsFlowHandler
* Use single class
* Simplify access to options
* Reduce PR
* Make _options private
* Add test
* Fix high latency at 0 microseconds
fixes#82231
* fix async_track_utc_time_change alignment
* use replace to preserve fold
* naming
* tweak
* make async_fire_time_changed aware of the thundering heard issue
* Create repairs issue if an outdated currency code is configured
* Add script for updating list of currencies
* Use black for formatting
* Move currency codes to a separate file
* Address review comments
* Add suggested_unit_of_measurement attribute to sensors
* Lazy calculation of initial entity options
* Add type alias for entity options
* Small tweak
* Add tests
* Store suggested_unit_of_measurement in its own option key
* Adapt to renaming of IMPERIAL_SYSTEM
* Fix rebase mistakes
* Apply suggestions from code review
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
* Improve check of new_entity_id in entity_registry.async_update_entity
* Fix race in rfxtrx config flow
* Make sure Event is created on time
* Rename poorly named variable
* Fix typing
* Correct typing of _handle_state_change
* Convert UnitConverter protocl to a class
* Remove logic change
* Use TypeVar
* Remove NORMALIZED_UNIT from pressure
* Reduce size of PR
* Reduce some more
* Once more
* Once more
* Remove DEVICE_CLASS
* Introduce ConversionUtility
* Use ConversionUtility in number
* Use ConversionUtility in sensor
* Use ConversionUtility in sensor recorder
* Add normalise to ConversionUtility
* Revert changes to recorder.py
* Reduce size of PR
* Adjust recorder statistics
* Rename variable
* Rename
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>