69 Commits

Author SHA1 Message Date
karwosts
86d7fdfe1e Allow history_stats to configure state_class: total_increasing (#148637) 2026-02-19 10:16:47 +01:00
epenet
f29daccb19 Remove outdated device registry cleanup in history_stats (#161862) 2026-01-31 15:14:42 +01:00
epenet
dbfdaf6a2e Use is over == comparison for FlowResultType in flow tests (#159158) 2025-12-16 09:48:45 +01:00
karwosts
d67ec7593a Add diagnostics to history_stats (#152460) 2025-09-17 00:02:35 +01:00
karwosts
ac154c020c Use a state selector for history_stats (#150445)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-09-10 23:52:50 +02:00
Marc Mueller
94f2118b19 Fix flaky history_stats test case (#149974) 2025-08-04 20:34:07 +02:00
Erik Montnemery
254f766357 Do not add history_stats config entry to source device (#148729) 2025-07-14 20:05:34 +02:00
karwosts
3cfff4de3a Add a preview to history_stats options flow (#145721) 2025-07-05 09:09:02 +02:00
Erik Montnemery
cf5cdf3cdb Handle changes to source entity in history_stats helper (#146521) 2025-06-11 15:16:51 +02:00
epenet
695f69bd90 Remove unnecessary DOMAIN alias in tests (e-k) (#145818) 2025-05-28 21:06:25 +03:00
karwosts
7e895f7d10 Fix history_stats with sliding window that ends before now (#145117) 2025-05-19 20:03:59 +02:00
karwosts
8699e69ae5 Optimize sliding window history_stats to not re-query the database every interval (#143279)
Co-authored-by: J. Nick Koston <nick@koston.org>
2025-04-20 08:08:28 -10:00
Erik Montnemery
cc5c8bf5e3 Make helpers.frame.report_usage work when called from any thread (#139836)
* Make helpers.frame.report_usage work when called from any thread

* Address review comments, update tests

* Add test

* Update test

* Update recorder test

* Update tests
2025-03-05 19:37:34 +01:00
epenet
7b1b229718 Standardize homeassistant imports in component tests (a-l) (#136806) 2025-01-29 10:00:45 +01:00
karwosts
72e2b835d9 Fix a history stats bug when window and tracked state change simultaneously (#133770) 2024-12-23 22:47:26 +01:00
karwosts
889ac1552b Fix flaky test in history stats (#131869) 2024-11-28 20:51:23 +01:00
karwosts
3d499ab849 Dont count unrecorded time for history_stats (#126271) 2024-11-21 10:24:06 -06:00
G Johansson
df85067cae Add device link to History stats helper (#121848) 2024-07-12 16:01:50 +02:00
G Johansson
833ac4db49 Add config flow to history_stats helper (#121381) 2024-07-07 21:06:37 +02:00
J. Nick Koston
5a609c34bb Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
J. Nick Koston
29bfed72f7 Fix flaky history stats test (#115824) 2024-04-21 01:08:40 +02:00
Collin Fair
0636ba340c Fix flakiness of test_measure_sliding_window (#115322) 2024-04-09 18:28:06 -10:00
Joost Lekkerkerker
6bb4e7d62c Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
J. Nick Koston
65358c129a Replace periodic tasks with background tasks (#112726)
* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* one more
2024-03-08 21:45:10 -05:00
Marc Mueller
c88b337600 Add empty line after module docstring [tests f-k] (#112709) 2024-03-08 14:50:04 +01:00
Jan-Philipp Benecke
eda475fe25 Update h* tests to use entity & device registry fixtures (#103866)
* Update h* tests to use entity & device registry fixtures

* Add missed lines
2023-11-12 13:52:32 -05:00
Robert Resch
e4303e4534 Add rounding back when unique_id is not set (#97603) 2023-08-02 11:26:25 +02:00
Amos Yuen
d0512d5b26 Stop rounding history_stats sensor (#97195) 2023-07-26 08:09:50 +02:00
Piotr Tobolski
02b5d643e7 Add unique_id support to history_stats sensor (#92972) 2023-05-12 15:03:06 +02:00
J. Nick Koston
da4c144a5e Fix history stats query using incorrect microseconds (#91250) 2023-04-17 11:37:30 -10:00
J. Nick Koston
4e6937d20f Avoid multiple round trips to the database for history API calls (#91193)
* 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 d798b100ac45c7f8c4cee5d284d94beed5e3d454.

* 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 bf974e103e651a1334493a9594e08d19e51e392b.

* 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 119354499ecf7c1025ec40350e97e73d62d3fd4b.

* 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 (#89589)
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 (#88476) 2023-02-20 11:43:51 +01:00
Paulus Schoutsen
c557cd2b1e Make all history stats tests async (#87973) 2023-02-13 14:34:28 +01:00
epenet
03710e58b5 Add type hints to integration tests (part 9) (#87983) 2023-02-13 12:06:51 +01:00
Franck Nijhof
5e81d28116 Update black to 23.1.0 (#87188) 2023-02-02 18:35:24 +01:00
Franck Nijhof
a79885ceaf Enable Ruff SIM117 (#86783) 2023-01-27 11:52:49 +01:00
epenet
30bf0634fe Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +01:00
Paulus Schoutsen
a786b32857 Set date in test to fixed one (#81175) 2022-10-28 23:58:02 -04:00
Erik Montnemery
31a787558f Ensure recorder test fixture is setup before hass fixture (#80528)
* 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 (#77855) 2022-09-05 14:56:27 -04:00
J. Nick Koston
0505c596a5 Fix dropouts in history_stats graphs on restart (#73110) 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 (#72880) 2022-06-02 08:39:53 -07:00
J. Nick Koston
c74b241949 Include initial state in history_stats count (#71952) 2022-05-18 10:28:04 -07:00
J. Nick Koston
1dc15bb7c8 Prevent history_stats from rejecting states when microseconds differ (#71704) 2022-05-11 20:44:35 -07:00
J. Nick Koston
1304808f89 Add additional test cover for history_stats (#71648) 2022-05-11 13:09:55 +02:00
J. Nick Koston
aafe6ff0e2 Fix history_stats for timezones with a positive offset from UTC (#71038) 2022-04-28 23:48:58 -07:00
J. Nick Koston
1d2c949c51 Convert history_stats to use a coordinator (#70388)
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 (#70363)
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) (#70255) 2022-04-21 09:06:59 -07:00