125 Commits

Author SHA1 Message Date
epenet
7bb0414a39 Remove outdated device registry cleanup in statistics (#161865) 2026-01-31 15:14:09 +01:00
Robert Resch
96f84b2b99 Sort homeassistant json files (#155285) 2025-10-28 10:33:10 +01:00
G Johansson
e5658f9747 Use automatic reload options flow in statistics (#152682) 2025-09-22 11:48:58 +02:00
Erik Montnemery
1743766d17 Add last_reported to state reported event data (#148932) 2025-07-18 13:53:30 +02:00
Erik Montnemery
3cb579d585 Do not add statistics config entry to source device (#148731) 2025-07-15 22:13:26 +02:00
Erik Montnemery
cb9c213496 Handle changes to source entity in statistics helper (#146523) 2025-06-11 15:17:19 +02:00
karwosts
19259d5cad Add read_only selectors to Statistics Options Flow (#145522) 2025-05-23 17:58:45 +02:00
Christopher Fenner
1579e90d58 Fix typos in strings.json files (#138601)
* fix codespell issues

* update nextcloud snapshots

* update weheat snapshots

* update waqi snapshots
2025-02-18 22:36:28 +01:00
Erik Montnemery
f83c8de8d3 Update signature of platforms' async_setup_entry (#138201) 2025-02-10 21:08:03 +01:00
Norbert Rittel
123cd92986 Replace keys with translatable friendly names in Statistics helper (#136936) 2025-02-01 10:48:05 +01:00
G Johansson
76b73fa9b1 Use floats instead of datetime in statistics (#132746)
* Use floats instead of datetime in statistics

* check if debug log
2024-12-10 19:03:43 +01:00
G Johansson
3be0d0d085 Add myself as code owner to statistics (#132719) 2024-12-09 16:04:47 +01:00
G Johansson
74eddce3d3 Change to module function in statistics (#132648) 2024-12-09 15:23:21 +01:00
Norbert Rittel
913ec53f8c Replace "Add" with "Create" in description of Helper (#131407)
The user can create Statistics helpers for different purposes.

Following the HA Design guidelines this means that the description in the dialog should use "Create" not "Add".
2024-11-23 22:58:38 +01:00
G Johansson
50cc6b4e01 Use shorthand attribute for extra state attributes in statistics (#129353) 2024-11-15 17:37:57 +01:00
G Johansson
285468d85f Fix translation in statistics (#130455)
* Fix translation in statistics

* Update homeassistant/components/statistics/strings.json
2024-11-12 18:44:32 +01:00
G Johansson
9546bf1dee Use shorthand attribute for native value in statistics (#129355) 2024-10-28 22:43:09 +01:00
G Johansson
73f2d972e4 Use shorthand attribute for available in statistics (#129354) 2024-10-28 21:01:34 +01:00
G Johansson
7d699c6c35 Fix calculation of attributes in statistics (#128475)
* Fix calculation of attributes in statistics

* Cleanup

* Mods

* Fix device class

* Typing

* Mod uom calc

* Fix UoM

* Fix docstrings

* state class docstring
2024-10-28 19:45:47 +01:00
unfug-at-github
50ccce7387 React to state report events to increase sample size of statistics (#129211)
* react to state reported events to increase sample size

* added test case for timinig and minor corrections
2024-10-28 14:41:48 +01:00
unfug-at-github
c5ed148c52 Fix race condition in statistics that created spikes (#129066)
* fixed race condition and added test case for updates before db load

* removed duplicated code

* improved comments, removed superfluous errors / assertions

* allow both possible outcomes of race condition

* use approx for float comparison

* Update tests/components/statistics/test_sensor.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* force new state before database load in race condition test

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-10-26 09:23:47 +02:00
unfug-at-github
9ec4881d8d Have statistics functions return a meaningful, non-none result even if only one value is available (#127305)
* have statistics functions return a meaningful, non-none result even if only one value is available

* improved code coverage
2024-10-23 16:02:46 +02:00
G Johansson
7178943223 Add translatable title to statistics (#128286) 2024-10-13 14:37:57 +02:00
G Johansson
80582a128a Fix preview available in statistics (#127349) 2024-10-03 22:27:01 +02:00
G Johansson
2ff88e7baf Add preview to statistics (#122590) 2024-09-27 21:09:42 +02:00
Erik Montnemery
38ef216894 Update icons.json to new service schema part 4 (#124771) 2024-08-28 13:48:13 +02:00
dougiteixeira
4437c4a204 Link the Statistics helper entity to the source entity device (#120705) 2024-06-28 12:22:24 +02:00
G Johansson
3d5d4f8ddb Add config flow to statistics (#120496) 2024-06-26 16:06:35 +02:00
Marc Mueller
3559755aed Add import aliases for PLATFORM_SCHEMA (#120445) 2024-06-25 19:16:19 +02:00
J. Nick Koston
c8e6292cb7 Refactor statistics to avoid creating tasks (#116743) 2024-05-05 16:39:45 -04:00
Sid
3799d20d43 Enable Ruff B905 (#114197) 2024-04-14 00:14:26 -05:00
Sid
0d66d298ec Enable Ruff RET504 (#114528)
* Enable Ruff RET504

* fix test

* Use noqa instead of cast

* fix sonos RET504

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-06 11:07:37 +02:00
Marc Mueller
0f03079065 Update import for EventStateChangedData [i-z] (#114900) 2024-04-04 11:48:29 -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
Joost Lekkerkerker
73af5f5be1 Add service icons to Statistics (#113353) 2024-03-14 10:59:49 +01:00
Marc Mueller
84c44c1835 Replace EventType with Event [l-s] (#112741) 2024-03-08 19:37:18 +01:00
Marc Mueller
cb8c14496c Use more f-strings [ruff] (#112695) 2024-03-08 18:44:42 +01:00
Marc Mueller
930a396712 Add empty line after module docstring [s] (#112704) 2024-03-08 14:33:51 +01:00
Brenan Kelley
458c5ae657 Add statistics keep_last_sample option (#88655)
* introduce preserve last value option

* improve comments

* add unit test

* skip scheduling purge on a preserved value

* do not schedule sensor update if preserving last value

* fix unit test to use new mock time pattern

pattern introduced in https://github.com/home-assistant/core/pull/93499

* rename preserve_last_val to keep_last_sample

* add keep_last_sample config validation
2024-02-27 13:17:05 +01:00
Joost Lekkerkerker
730d805876 Enable SIM114 ruff rule (#111125) 2024-02-23 13:21:59 +01:00
enzo2
35be5957c3 Add circular mean to statistics integration (#98930)
* Add circular mean

Add support for circular mean for sensors in units of degrees, e.g. direction data.

* Update test_sensor.py

* Update sensor.py

* Remove whitespace

* Revert to degC

* Fix: shift atan2 output to positive degrees

* Add new dedicated test

* Simplify test
2023-10-07 13:51:27 +02:00
Erik Montnemery
d1afcd773f Revert "Cache entity properties that are never expected to change in the base class" (#100422)
Revert "Cache entity properties that are never expected to change in the base class (#95315)"

This reverts commit 042776ebb8.
2023-09-15 11:25:24 +02:00
J. Nick Koston
042776ebb8 Cache entity properties that are never expected to change in the base class (#95315) 2023-09-14 17:48:48 -05:00
Marc Mueller
8c870a5683 Use EventType for state changed [m-z] (#97118) 2023-07-24 08:07:07 +02:00
Joost Lekkerkerker
b367c95c81 Add more common translations (#96429)
* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations
2023-07-12 22:00:05 -04:00
Franck Nijhof
c431fc2297 Migrate reload only helper services to support translations (#96344) 2023-07-11 20:56:21 +02:00
epenet
0e1c76f81f Improve sensor type hints in integrations (#90031)
* Improve sensor type hints in integrations

* Improve
2023-03-21 11:39:42 +01:00
Thomas Dietrich
ee8f746808 Change statistics component ownership (#88692) 2023-02-24 08:11:40 -05:00
epenet
ccf44d58cc Expose DEVICE_CLASS_STATE_CLASSES sensor constant (#88172) 2023-02-15 14:48:27 +01:00
epenet
443d446cbf Remove invalid pragma: no cover (#88173) 2023-02-15 14:39:12 +01:00