* Use parent_id to find cause of events with new contexts
When looking up the causing event for logbook display, use the `parent_id`
of the current context if the current context just points back to the
current event.
This now shows in the logbook the cause of an event in the case that a
component has created a new context from an existing context and tied
them together via the `Context.parent_id`.
* Fix exception when parent event not available
* Use async_Log_entry to avoid jump into executor
* Provide a logbook option entity_matches_only to optimize for single entity id lookup
When entity_matches_only is provided, contexts and events that do not
contain the entity_id are not included in the logbook response.
* Update homeassistant/components/logbook/__init__.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* api only takes a single entity
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* Include the context_entity_id in the logbook api
context_entity_id is the first entity seen during
a time period that includes the context
* update test
* more of them
* include friendly name
* pylint wants a ternary
* Refactor
* performance
* fix homekit context
* Fix self describing events
* Fix external_events
* Remove support for legacy logbook events created before 0.112
Reduce the complexity of the logbook code. This
should also have a small performance boost.
* None is the default
* Move logbook continuous domain filtering to sql
sensors tend to generate a significant amount of states
that are filtered out by logbook. In testing 75% of
states can be filtered away in sql to avoid the
sqlalchemy ORM overhead of creating objects that will
be discarded.
* remove un-needed nesting
* Added GLOB capability to entityfilter and every place that uses it. All existing tests are passing
* added tests for components affected by glob change
* fixed flake8 error
* mocking the correct listener
* mocking correct bus method in azure test
* tests passing in 3.7 and 3.8
* fixed formatting issue from rebase/conflict
* Checking against glob patterns in more performant way
* perf improvments and reverted unnecessarily adjusted tests
* added new benchmark test around filters
* no longer using get with default in entityfilter
* changed filter name and removed logbook from filter benchmark
* simplified benchmark tests from feedback
* fixed apache tests and returned include exclude schemas to normal
* fixed azure event hub tests to properly go through component logic
* fixed azure test and clean up for other tests
* renaming test files to match standard
* merged mqtt statestream test changes with base
* removed dependency on recorder filter schema from history
* fixed recorder tests after merge and a bunch of lint errors
* adj
* time_fired_isoformat
* remove unused code
* tests for processing timestamps
* restore missing import lost in merge conflict
* test for None case
* Prefilter more logbook events in sql
Prefilter sensor events in _keep_event before humanify
Cache static attribute lookup
Reduces logbook execution time by ~35%
* fix mocking in benchmark
* Update tests for logbook users
* Add old_state_id to states, remove old/new state data from events since it can now be found by a join
* remove state lookup on restart
* Ensure old_state is set for exisitng states
* Only process logbook timestamps for events we will keep
Since we group by minute we were previously processing
every timestamp. We can avoid this by making all the
minute checks use the unprocessed datetime since
the groupings will be the same regardless of timezone.
This reduces the number of datetime object recreations
by at least an order of magnitude.
* Ensure HomeAssistant can startup if homekit fails to load
* Update homeassistant/components/logbook/manifest.json
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Add yamllint (in pre-commit and CI)
* Fix linting for all YAML files
* Bump and add it to requirements
* Fix gen_requirements for pre-commit, remove 'v' from version
* Use f-strings in integrations starting with "H"
* Use f-strings in integrations starting with "I"
* Use f-strings in integrations starting with "J"
* Use f-strings in integrations starting with "K"
* Use f-strings in integrations starting with "L"
* Fix lint error
* Use join instead of f-string in homekit_controller
* Use local variables with f-strings
* Fix lint error
* Escape the characters in f-string
* Sort imports with isort in homeworks light
* Fix pylint error
* Fix broken tests
* Fix broken tests v2