Commit Graph

148 Commits (e9a9ab9025c16ed186599d605008e3a7692a805b)

Author SHA1 Message Date
epenet 5442d6af01
Improve msg type hint in websocket commands (#80530) 2022-10-18 16:41:17 +02:00
Franck Nijhof 2b27cfdabb
Set system & entity integration types (#79593) 2022-10-04 10:36:42 -04:00
epenet 7871a517a8
Import constants from root (#78271) 2022-09-12 18:53:05 +02:00
epenet 0d2465cf0a
Expose logbook constants at the top level (#78184) 2022-09-10 23:44:03 +02:00
J. Nick Koston fcb6888f87
Start logbook stream faster (#77921)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-09-09 17:16:02 -05:00
J. Nick Koston 720768560d
Fix devices missing in logbook when all requested entities are filtered (#74073) 2022-06-28 08:44:06 +02:00
J. Nick Koston f29cc33fa0
Fix selecting entity_ids and device_ids in events with MySQL and PostgreSQL with logbook (#73918)
* Fix selecting entity_ids and device_ids in events with MySQL and PostgreSQL

Fixes #73818

* add cover
2022-06-24 15:43:35 +02:00
J. Nick Koston 28dd92d928
Fix logbook state query with postgresql (#73924) 2022-06-23 23:35:10 +02:00
J. Nick Koston 00a79635c1
Revert "Remove sqlalchemy lambda_stmt usage from history, logbook, and statistics (#73191)" (#73917) 2022-06-23 13:59:55 -05:00
J. Nick Koston 8b067e83f7
Initial orjson support take 3 (#73849)
* 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
2022-06-22 21:59:51 +02:00
J. Nick Koston fcd8859542
Remove self from logbook codeowners (#73724) 2022-06-19 22:24:42 -04:00
J. Nick Koston e4f354998d
Filter out forced updates in live logbook when the state has not changed (#73335) 2022-06-10 14:04:43 -07:00
J. Nick Koston 7ae8bd5137
Remove sqlalchemy lambda_stmt usage from history, logbook, and statistics (#73191) 2022-06-07 16:15:50 -07:00
Erik Montnemery 5f2b4001f3
Separate recorder database schema from other classes (#72977)
* Separate recorder database schema from other classes

* fix logbook imports

* migrate new tests

* few more

* last one

* fix merge

Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-07 14:41:43 +02:00
J. Nick Koston 0b62944148
Mark counter domain as continuous to exclude it from logbook (#73101) 2022-06-05 21:25:26 -10:00
J. Nick Koston 457c7a4ddc
Fix incompatiblity with live logbook and google_assistant (#73063) 2022-06-05 19:06:49 -10:00
J. Nick Koston 6b2e5858b3
Send an empty logbook response when all requested entity_ids are filtered away (#73046) 2022-06-05 21:14:47 -07:00
J. Nick Koston a9d45d656d
Add to codeowners for logbook so I get notifications (#72964)
- Adding explictly will get through my filters and I want
  to watch this one for at least this release
2022-06-03 15:49:17 +02:00
J. Nick Koston a28fa5377a
Remove unused code from logbook (#72950) 2022-06-03 08:59:00 +02:00
J. Nick Koston 9fbde245d0
Fix performance of logbook entity and devices queries with large MySQL databases (#72898) 2022-06-02 14:54:06 -07:00
J. Nick Koston 5d2326386d
Fix logbook spinner never disappearing when all entities are filtered (#72816) 2022-06-01 12:33:46 +02:00
J. Nick Koston c365454afb
Revert "Initial orjson support (#72754)" (#72789)
This was causing the wheels to fail to build. We need
to workout why when we don't have release pressure

This reverts commit d9d22a9556.
2022-05-31 13:51:55 -07:00
J. Nick Koston 35ee4ad55b
Prevent live logbook from sending state changed events when we only want device ids (#72780) 2022-05-31 13:08:04 -07:00
J. Nick Koston 935ef79156
Fix queries for logbook context_ids running in the wrong executor (#72778) 2022-05-31 12:24:18 -07:00
J. Nick Koston d9d22a9556
Initial orjson support (#72754) 2022-05-31 12:18:11 -07:00
J. Nick Koston 5dc4c89acc
Small performance improvement for matching logbook rows (#72750) 2022-05-31 10:41:33 +02:00
J. Nick Koston 587fd05603
Make logbook inherit the recorder filter (#72728) 2022-05-30 17:34:32 -07:00
J. Nick Koston bfa7693d18
Fixes for logbook filtering and add it to the live stream (#72501) 2022-05-25 15:17:08 -10:00
J. Nick Koston 1c25e1d7b1
Add metadata to logbook live stream websocket endpoint (#72394) 2022-05-23 22:37:47 -07:00
J. Nick Koston 9d95b9ab05
Chunk large logbook queries and add an end_time to the api so we stop sending events (#72351) 2022-05-23 15:40:00 -07:00
J. Nick Koston 0248a8710f
Always pass the source of the trigger for logbook context messages (#72333) 2022-05-23 13:35:45 -05:00
J. Nick Koston 9c3f949165
Add live streaming logbook websocket endpoint (#72258)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-05-22 14:57:54 -05:00
J. Nick Koston d459a5c66e
Include context state in logbook responses to improve localization (#72222)
* Include context state in logbook responses to improve localization

* reduce payload, dont send context_event_type if sending context_state
2022-05-20 07:46:01 -07:00
J. Nick Koston 272e65f56d
Fix device_ids being filtered when entities also specified in the logbook (#72122) 2022-05-18 23:27:31 -05:00
J. Nick Koston 985bcb23f2
Fix SAWarning in logbook queries (#72101) 2022-05-18 12:33:58 -05:00
J. Nick Koston c4fc84ec1e
Add support for selecting device_ids from the logbook (#72039)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-05-18 01:58:30 -05:00
J. Nick Koston ec01e00184
Small cleanup to logbook context augmenter (#72043) 2022-05-17 21:10:28 -07:00
Paulus Schoutsen 5433c0a535
Make sure empty get_events results is always a list (#72021) 2022-05-17 10:43:58 -07:00
J. Nick Koston 089eb9960a
Reduce logbook websocket payload size and parse json attributes via the DBM (#71895) 2022-05-15 20:48:57 -07:00
J. Nick Koston 1f753ecd88
Relocate sqlalchemy filter builder to recorder/filters.py (#71883) 2022-05-14 23:04:23 -07:00
J. Nick Koston 8f33437507
Correct typo in internal logbook function names (#71882) 2022-05-14 20:04:31 -07:00
J. Nick Koston 0584e84c30
Add MySQL index hints to logbook (#71864)
* Add MySQL index hints to logbook

* fix mysql query planner
2022-05-14 17:01:36 -05:00
J. Nick Koston 68632cb267
Implement use_include_order in the history websocket api (#71839) 2022-05-14 12:37:35 -07:00
J. Nick Koston 8c2743bb67
Avoid storing last_changed in the database if its the same as last_updated (#71843) 2022-05-14 12:06:31 -07:00
J. Nick Koston 663f6f8340
Complete refactoring of logbook humanify (#71830) 2022-05-13 14:56:16 -07:00
J. Nick Koston 535ae56fe7
Remove unused entity_id argument in logbook context augmenter (#71829) 2022-05-13 13:17:41 -07:00
J. Nick Koston 2a2a7a62c5
Avoid matching entity_id/domain attributes in logbook when there is no entities_filter (#71825) 2022-05-13 13:16:33 -07:00
J. Nick Koston 9bd508c0bf
Generate json for history and logbook websocket responses in the executor (#71813) 2022-05-13 13:17:54 -04:00
J. Nick Koston d215cdc563
Avoid buffering logbook rows unless we are selecting less than a days worth (#71809) 2022-05-13 09:10:43 -07:00
J. Nick Koston e7e45209ec
Update stale docstring in logbook (#71814) 2022-05-13 09:07:26 -07:00