Commit graph

41 commits

Author SHA1 Message Date
Piotr Tobolski
02b5d643e7
Add unique_id support to history_stats sensor () 2023-05-12 15:03:06 +02:00
J. Nick Koston
da4c144a5e
Fix history stats query using incorrect microseconds () 2023-04-17 11:37:30 -10:00
J. Nick Koston
4e6937d20f
Avoid multiple round trips to the database for history API calls ()
* delete more code

* tweak

* tweak

* wrappers

* restore lost performance

* restore lost performance

* restore lost performance

* compact

* reduce

* fix refactor

* DRY

* tweak

* delete the start time state injector

* move away the legacy code

* tweak

* adjust

* adjust

* tweak

* ignore impossible

* fix a bug where the first start was changed to the start time when there was no previous history recorded before

* avoid the empty scan most cases

* postgresql

* fixes

* workaround for mariadb < 10.4

* remove unused

* remove unused

* adjust

* bail early

* tweak

* tweak

* fix more tests

* fix recorderrun being init in the future in the test

* run history tests on schema 30 as well

* Revert "run history tests on schema 30 as well"

This reverts commit d798b100ac.

* reduce

* cleanup

* tweak

* reduce

* prune

* adjust

* adjust

* adjust

* reverse later is faster because the index is in forward order and the data size we are reversing is much smaller even if we are in python code

* Revert "reverse later is faster because the index is in forward order and the data size we are reversing is much smaller even if we are in python code"

This reverts commit bf974e103e.

* fix test

* Revert "Revert "reverse later is faster because the index is in forward order and the data size we are reversing is much smaller even if we are in python code""

This reverts commit 119354499e.

* more coverage

* adjust

* fix for table order

* impossible for it to be missing

* remove some more legacy from the all states
2023-04-11 22:38:23 -04:00
J. Nick Koston
4dcf7c6267
Fix history_stats test failing during DST ()
Note that there is one test that needs `now()` as it is
timezone aware
2023-03-12 23:03:48 -04:00
epenet
ec5c3d6330
Add type hints to integration tests () 2023-02-20 11:43:51 +01:00
Paulus Schoutsen
c557cd2b1e
Make all history stats tests async () 2023-02-13 14:34:28 +01:00
epenet
03710e58b5
Add type hints to integration tests (part 9) () 2023-02-13 12:06:51 +01:00
Franck Nijhof
5e81d28116
Update black to 23.1.0 () 2023-02-02 18:35:24 +01:00
Franck Nijhof
a79885ceaf
Enable Ruff SIM117 () 2023-01-27 11:52:49 +01:00
epenet
30bf0634fe
Add per-file-ignore to pylint () 2023-01-22 17:26:24 +01:00
Paulus Schoutsen
a786b32857
Set date in test to fixed one () 2022-10-28 23:58:02 -04:00
Erik Montnemery
31a787558f
Ensure recorder test fixture is setup before hass fixture ()
* Ensure recorder test fixture is setup before hass fixture

* Adjust more tests
2022-10-19 07:58:47 +02:00
J. Nick Koston
6644f62ad2
Fix history stats device class when type is not time () 2022-09-05 14:56:27 -04:00
J. Nick Koston
0505c596a5
Fix dropouts in history_stats graphs on restart () 2022-06-09 21:11:23 -07:00
J. Nick Koston
d3b1896a06
Only present history_stats state as unknown if the time is in the future () 2022-06-02 08:39:53 -07:00
J. Nick Koston
c74b241949
Include initial state in history_stats count () 2022-05-18 10:28:04 -07:00
J. Nick Koston
1dc15bb7c8
Prevent history_stats from rejecting states when microseconds differ () 2022-05-11 20:44:35 -07:00
J. Nick Koston
1304808f89
Add additional test cover for history_stats () 2022-05-11 13:09:55 +02:00
J. Nick Koston
aafe6ff0e2
Fix history_stats for timezones with a positive offset from UTC () 2022-04-28 23:48:58 -07:00
J. Nick Koston
1d2c949c51
Convert history_stats to use a coordinator ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-04-25 15:20:06 -07:00
Erik Montnemery
982e314de6
Use recorder_mock in tests ()
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-04-22 19:29:44 -10:00
J. Nick Koston
73a368c242
Refactor history_stats to minimize database access (part 2) () 2022-04-21 09:06:59 -07:00
J. Nick Koston
e70c8fa359
Refactor history_stats to minimize database access (part 1) () 2022-04-18 13:18:38 -10:00
Franck Nijhof
d645e80ccd
Clean up async_update_entity helper usage () 2022-03-25 15:22:58 -07:00
Paulus Schoutsen
31153ac155
Move fixtures part 1 () 2021-11-01 20:47:05 -07:00
Erik Montnemery
973f59e423
Refactor history component ()
* Refactor history component

* Update tests

* Address review comments

* Correct deprecated functions
2021-05-11 09:21:57 +02:00
J. Nick Koston
bf2d40adfe
Migrate from pytz to python-dateutil ()
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-05-07 22:46:26 -07:00
J. Nick Koston
df66f2a9da
Cleanup history states tests that were converted to async tests () 2021-04-20 08:21:41 -10:00
J. Nick Koston
b8001b951b
Avoid executor jumps in history stats when no update is needed () 2021-04-19 08:23:10 -07:00
Franck Nijhof
ad13a9295e
Merge multiple context managers in tests () 2021-03-27 09:17:15 +01:00
Franck Nijhof
65cf2fcb6f
Drop asynctest () 2021-01-01 22:31:56 +01:00
Indu Prakash
7213d5f31b
Support for multiple states in history_stats ()
Co-authored-by: Indu Prakash <6459774+InduPrakash@users.noreply.github.com>
2020-11-21 12:44:37 +01:00
J. Nick Koston
f914625b8a
Add the ability to reload history_stats platforms from yaml ()
* Add the ability to reload history_stats platforms from yaml

* Increase coverage and cleanup

* Fix coverage

* services.yaml
2020-08-28 00:22:43 -05:00
Paulus Schoutsen
c33edbe5bb
Use TestCase.addCleanup () 2020-06-08 12:26:40 -07:00
Paulus Schoutsen
276f3afb00
Do async_setup_platform in background ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-31 22:18:30 -07:00
Paulus Schoutsen
2af984917e
Use asynctest-mock in most places ()
* Use asynctest-mock in most places

* Fix broken patch in pilight
2020-05-03 11:27:19 -07:00
Ville Skyttä
e6388e186c
Remove unnecessary string literal concatenations () 2020-01-02 21:17:10 +02:00
Bas Nijholt
8b39957c56 Sort imports according to PEP8 for components starting with "H" () 2019-12-09 14:19:48 +01:00
Paulus Schoutsen
4de97abc3a Black 2019-07-31 12:25:30 -07:00
Penny Wood
22d9bee41a Template: Expand method to expand groups, and closest as filter ()
* Implement expand method

* Allow expand and closest to be used as filters

* Correct patch

* Addresses review comments
2019-06-22 00:32:32 -07:00
Penny Wood
f195ecca4b Consolidate all platforms that have tests ()
* Moved climate components with tests into platform dirs.

* Updated tests from climate component.

* Moved binary_sensor components with tests into platform dirs.

* Updated tests from binary_sensor component.

* Moved calendar components with tests into platform dirs.

* Updated tests from calendar component.

* Moved camera components with tests into platform dirs.

* Updated tests from camera component.

* Moved cover components with tests into platform dirs.

* Updated tests from cover component.

* Moved device_tracker components with tests into platform dirs.

* Updated tests from device_tracker component.

* Moved fan components with tests into platform dirs.

* Updated tests from fan component.

* Moved geo_location components with tests into platform dirs.

* Updated tests from geo_location component.

* Moved image_processing components with tests into platform dirs.

* Updated tests from image_processing component.

* Moved light components with tests into platform dirs.

* Updated tests from light component.

* Moved lock components with tests into platform dirs.

* Moved media_player components with tests into platform dirs.

* Updated tests from media_player component.

* Moved scene components with tests into platform dirs.

* Moved sensor components with tests into platform dirs.

* Updated tests from sensor component.

* Moved switch components with tests into platform dirs.

* Updated tests from sensor component.

* Moved vacuum components with tests into platform dirs.

* Updated tests from vacuum component.

* Moved weather components with tests into platform dirs.

* Fixed __init__.py files

* Fixes for stuff moved as part of this branch.

* Fix stuff needed to merge with balloob's branch.

* Formatting issues.

* Missing __init__.py files.

* Fix-ups

* Fixup

* Regenerated requirements.

* Linting errors fixed.

* Fixed more broken tests.

* Missing init files.

* Fix broken tests.

* More broken tests

* There seems to be a thread race condition.
I suspect the logger stuff is running in another thread, which means waiting until the aio loop is done is missing the log messages.
Used sleep instead because that allows the logger thread to run. I think the api_streams sensor might not be thread safe.

* Disabled tests, will remove sensor in 

* Updated coverage and codeowners.
2019-03-18 23:07:39 -07:00