* 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>
* Switch dispatcher to use async_run_hass_job
- Since we already wrap all the callbacks in catch_log_exception
we can use async_run_hass_job here
- The overhead of wrapping the call in a call_soon, queuing it
and running it later usually exceeds the overhead of running
the job itself
* fix size change during iteration
* fix out of order send
* fix missing mocking in unifi test
* Fix Legrand Home+ Control updating entities before the coordinator update had finished
* stray debug
* Speed up generation of template states
* tweak
* cache
* cache hash
* weaken
* Revert "weaken"
This reverts commit 4856f50080.
* lower cache size as it tends to be the same ones over and over
* lower cache size as it tends to be the same ones over and over
* lower cache size as it tends to be the same ones over and over
* cover
* Update homeassistant/helpers/template.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* id reuse is possible
* account for iterting all sensors
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
- These were using orjson directly, its a bit cleaner
to use the helper so everything is easier to adjust
in the future if we need to change anything about
the loading
* Initial orjson support take 2
Still need to work out problem building wheels
--
Redux of #72754 / #32153 Now possible since the following is solved:
ijl/orjson#220 (comment)
This implements orjson where we use our default encoder. This does not implement orjson where `ExtendedJSONEncoder` is used as these areas tend to be called far less frequently. If its desired, this could be done in a followup, but it seemed like a case of diminishing returns (except maybe for large diagnostics files, or traces, but those are not expected to be downloaded frequently).
Areas where this makes a perceptible difference:
- Anything that subscribes to entities (Initial subscribe_entities payload)
- Initial download of registries on first connection / restore
- History queries
- Saving states to the database
- Large logbook queries
- Anything that subscribes to events (appdaemon)
Cavets:
orjson supports serializing dataclasses natively (and much faster) which
eliminates the need to implement `as_dict` in many places
when the data is already in a dataclass. This works
well as long as all the data in the dataclass can also
be serialized. I audited all places where we have an `as_dict`
for a dataclass and found only backups needs to be adjusted (support for `Path` needed to be added for backups). I was a little bit worried about `SensorExtraStoredData` with `Decimal` but it all seems to work out from since it converts it before it gets to the json encoding cc @dgomes
If it turns out to be a problem we can disable this
with option |= [orjson.OPT_PASSTHROUGH_DATACLASS](https://github.com/ijl/orjson#opt_passthrough_dataclass) and it
will fallback to `as_dict`
Its quite impressive for history queries
<img width="1271" alt="Screen_Shot_2022-05-30_at_23_46_30" src="https://user-images.githubusercontent.com/663432/171145699-661ad9db-d91d-4b2d-9c1a-9d7866c03a73.png">
* use for views as well
* handle UnicodeEncodeError
* tweak
* DRY
* DRY
* not needed
* fix tests
* Update tests/components/http/test_view.py
* Update tests/components/http/test_view.py
* black
* templates
* Update the nest integration to be useable fully from the config flow
* Support discovery in nest config flow
* Remove configuration entries
* Remove unused import
* Remove dead code
* Update homeassistant/components/nest/strings.json
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Remove commented out code
* Use config flow for app auth reauthentication path
* Improves for re-auth for upgrading existing project and creds
* More dead code removal
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Remove outdated code
* Update homeassistant/components/nest/config_flow.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Reduce overhead to refire events
- asyncio timers can fire early for a varity of reasons including
poor clock resolution and performance. To solve this problem
we re-arm async_track_point_in_utc_time and try again later
when this happens.
- On some platforms this means the async_track_point_in_utc_time can
end up trying many times to prevent firing the timer early since as
soon as it rearms it fires again and this repeats until we reach
the appointed time. While there is not much we can do to prevent
asyncio from firing the timer callback early, we can reduce the
overhead when this happens by using avoiding creating datetime
objects
* tweak mocking
* -vvv
* fix time freeze being too broad in litterrobot
* adjust
* Refactor template entity to allow reuse
* Fix schema and default name
* Add tests
* Update requirements
* Improve test
* Tweak TemplateSensor initializer
* Drop attributes and availability from TemplateEntity
* Use rest sensor for proof of concept
* Revert changes in SNMP sensor
* Don't set _attr_should_poll in mixin class
* Update requirements
* Remove async_remove_listener
This avoids the ambuigity as to what happens if same callback is added multiple times.
* Keep track of a context for each listener
This allow a update coordinator to adapt what data to request on update from the backing service based on which entities are enabled.
* Clone list before calling callbacks
The callbacks can end up unregistering and modifying the dict while iterating.
* Only yield actual values
* Add a test for update context
* Factor out iteration of _listeners to helper
* Verify context is passed to coordinator
* Switch to Any as type instead of object
* Remove function which use was dropped earliers
The use was removed in 8bee25c938
* Add return code to integration application credentials in config flow
* Update google tests to use new return code
* Update spotify test for no auth configured
* Add translation for oauth2_missing_credentials
* Add new return code to yolink
* Update homeassistant/strings.json
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Initial developer credentials scaffolding
- Support websocket list/add/delete
- Add developer credentials protocol from yaml config
- Handle OAuth credential registration and de-registration
- Tests for websocket and integration based registration
* Fix pydoc text
* Remove translations and update owners
* Update homeassistant/components/developer_credentials/__init__.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* Update homeassistant/components/developer_credentials/__init__.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* Remove _async_get_developer_credential
* Rename to application credentials platform
* Fix race condition and add import support
* Increase code coverage (92%)
* Increase test coverage 93%
* Increase test coverage (94%)
* Increase test coverage (97%)
* Increase test covearge (98%)
* Increase test coverage (99%)
* Increase test coverage (100%)
* Remove http router frozen comment
* Remove auth domain override on import
* Remove debug statement
* Don't import the same client id multiple times
* Add auth dependency for local oauth implementation
* Revert older oauth2 changes from merge
* Update homeassistant/components/application_credentials/__init__.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Move config credential import to its own fixture
* Override the mock_application_credentials_integration fixture instead per test
* Update application credentials
* Add dictionary typing
* Use f-strings as per feedback
* Add additional structure needed for an MVP application credential
Add additional structure needed for an MVP, including a target
component Xbox
* Add websocket to list supported integrations for frontend selector
* Application credentials config
* Import xbox credentials
* Remove unnecessary async calls
* Update script/hassfest/application_credentials.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Update script/hassfest/application_credentials.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Update script/hassfest/application_credentials.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Update script/hassfest/application_credentials.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Import credentials with a fixed auth domain
Resolve an issue with compatibility of exisiting config entries when importing
client credentials
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>