1
0
mirror of https://github.com/home-assistant/core.git synced 2025-06-28 00:47:10 +00:00

127 Commits

Author SHA1 Message Date
J. Nick Koston
50edc334de
Refactor sensor recorder _get_sensor_states to check for state class first ()
The state class check is cheap and the entity filter check is much
more expensive, so do the state class check first
2024-01-07 22:36:03 -05:00
Marc Mueller
a70ec64408
Update mypy to 1.7.0 () 2023-11-11 23:31:04 +01:00
J. Nick Koston
c6ed022cce
Fix compiling missing statistics losing rows () 2023-10-08 19:43:00 +02:00
Erik Montnemery
659d437cac
Use loader.async_suggest_report_issue in sensor () 2023-10-05 20:07:56 +02:00
Erik Montnemery
df73850f56
Move definition of attributes excluded from history to entity classes ()
* Move definition of attributes excluded from history to entity classes

* Revert change which should be in a follow-up PR

* Fix sun unrecorded attributes

* Fix input_select unrecorded attributes
2023-09-21 15:02:47 +02:00
Erik Montnemery
51576b7214
Improve typing of entity.entity_sources ()
* Improve typing of entity.entity_sources

* Calculate entity info source when generating WS response

* Adjust typing

* Update tests
2023-09-12 20:41:26 +02:00
Erik Montnemery
e1f0b44ba4
Use math.isfinite instead of explicitly checking for both nan and inf () 2023-08-09 14:13:57 +02:00
J. Nick Koston
3f9d5a0192
Use the converter factory in sensor.recorder._normalize_states ()
We have a factory to create converters now which avoids
the overhead of calling convert to create the converter
every time
2023-07-03 14:20:23 -04:00
J. Nick Koston
bb4c03ce3c
Avoid returning statistics columns that the metadata knows are impossible () 2023-04-30 20:46:26 +02:00
J. Nick Koston
88ad97f112
Fix generating statistics for time periods smaller than we can measure ()
If the time period for the mean/time weighted average was smaller
than we can measure (less than one microsecond), generating
statistics would fail with a divide by zero error. This is likely
only happens if the database schema precision is incorrect.
2023-03-21 21:12:45 -04:00
J. Nick Koston
5ffb233004
Avoid database executor job to fetch statistic metadata on cache hit ()
* Avoid database executor job to fetch statistic metadata on cache hit

Since we will almost always have a cache hit fetching
statistic meta data we can avoid an executor job

* Avoid database executor job to fetch statistic metadata on cache hit

Since we will almost always have a cache hit fetching
statistic meta data we can avoid an executor job

* Avoid database executor job to fetch statistic metadata on cache hit

Since we will almost always have a cache hit fetching
statistic meta data we can avoid an executor job

* remove exception catch since the threading.excepthook will actually catch this in production

* fix a few missed ones

* threadsafe

* Update homeassistant/components/recorder/table_managers/statistics_meta.py

* coverage and optimistic caching
2023-03-19 22:01:16 -04:00
J. Nick Koston
f6f3565796
Reduce latency to find stats metadata () 2023-03-16 19:00:02 -10:00
J. Nick Koston
a6d6807dd0
Add typing to statistics results () 2023-03-14 09:06:56 -10:00
avee87
1519a78567
Fix log message in recorder on total_increasing reset () 2023-02-25 12:05:24 +01:00
J. Nick Koston
b054296c42
Speed up selecting which statistics to compile () 2023-02-12 18:15:27 +01:00
J. Nick Koston
85649ec589
Reduce overhead to see if an entity is recorded ()
A significant chunk of list_statistic_ids was checking if the entity
was recorded because it had to get the recorder instance over and
over
2023-02-11 23:21:16 -05:00
J. Nick Koston
c35661947a
Optimize fetching statistics by avoiding timestamp conversions ()
* Optimize fetching statistics by avoiding timestamp conversions

* remove accidential unrelated change

* fix test

* recreate so we handle timezone changes
2023-02-10 11:26:46 -05:00
epenet
810367b757
Fix can not typo () 2023-02-03 11:37:16 +01:00
Erik Montnemery
91668f8599
Use SensorStateClass enum in sensor ()
* Use SensorStateClass enum in sensor

* Apply suggestions from code review

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Update homeassistant/components/sensor/recorder.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-02-03 10:49:41 +01:00
Erik Montnemery
b0d4b73874
Add unitless unit converter ()
* Add unitless unit converter

* Adjust type hints

* Adjust tests

* Rename to UnitlessRatioConverter
2023-01-12 09:20:00 +01:00
Franck Nijhof
cf5fca0464
Code styling tweaks to core entity components () 2023-01-08 13:40:08 -10:00
Franck Nijhof
f39f3b612a
String formatting and max line length - Part 5 ()
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
2022-12-23 16:43:17 +01:00
epenet
96c442349f
Introduce unit enums for sound pressure ()
* Introduce unit enums for sound pressure

* Adjust based on architecture comment

* Adjust
2022-12-08 20:06:02 +01:00
epenet
90438edc17
Introduce unit enums for irradiance () 2022-12-08 18:41:38 +01:00
Franck Nijhof
ce00f093d6
Add enum device_class and state options property to sensor entities () 2022-12-02 09:11:15 +01:00
Erik Montnemery
607a0e7697
Reduce size of get_statistics_during_period WS API response () 2022-11-16 17:36:30 +01:00
Erik Montnemery
3d3349240f
Don't trigger statistics issues when sensor units are equivalent () 2022-10-25 09:50:01 +02:00
Erik Montnemery
577f7904b5
Minor improvements of recorder typing ()
* Minor improvements of recorder typing

* Only allow specifying statistic_ids as lists
2022-10-12 14:59:10 +02:00
Erik Montnemery
a391b8dd9d
Support correcting sensor volume unit () 2022-10-11 13:51:28 +02:00
Erik Montnemery
c52b900bfe
Minor cleanup of sensor statistics () 2022-10-11 12:24:52 +02:00
Erik Montnemery
69d935b7bd
Teach long term statistics that unit 'rpm' is same as 'RPM' ()
* Teach long term statistics that unit 'rpm' is same as 'RPM'

* Add tests
2022-10-11 10:32:01 +02:00
Erik Montnemery
aa5575ba65
Only validate sensors in sensor.recorder.validate_statistics () 2022-10-06 21:17:46 +02:00
Erik Montnemery
0a59d37e62
Correct how unit used for statistics is determined () 2022-10-06 14:01:54 -04:00
Erik Montnemery
e93deaa8aa
Simplify long term statistics by always supporting unit conversion () 2022-10-03 21:50:05 -04:00
Erik Montnemery
a2e3978d53
Don't normalize units of long term statistics ()
* Don't normalize units of long term statistics

* Update statistics.py
2022-10-03 21:42:44 +02:00
Erik Montnemery
2de273500e
Remove state_unit_of_measurement from metadata DB table ()
* Remove state_unit_of_measurement from metadata DB table

* Adjust test
2022-10-01 18:55:00 +02:00
epenet
5389ff3253
Add new weight device class () 2022-09-28 12:13:49 +02:00
Erik Montnemery
9084beda32
Keep storing statistics for sensors which change device class () 2022-09-27 14:33:28 -04:00
epenet
12e4d18038
Add volume to SensorDeviceClass ()
* Add volume to SensorDeviceClass

* Adjust recorder

* Adjust tests

* Adjust sensor UNIT_CONVERTERS

* Adjust recorder

* Update strings.json
2022-09-27 19:37:52 +02:00
epenet
7c448416e1
Add speed to SensorDeviceClass ()
* Add speed to SensorDeviceClass

* Adjust recorder

* Adjust tests

* Adjust sensor UNIT_CONVERTERS

* Add tests

* Add websocket tests

* Update strings.json
2022-09-27 17:19:34 +01:00
epenet
bfcc18e5b8
Add distance to SensorDeviceClass ()
* Add distance to SensorDeviceClass

* Adjust recorder

* Adjust tests

* Adjust recorder

* Update __init__.py

* Update test_websocket_api.py

* Update test_websocket_api.py

* Update test_websocket_api.py

* Update strings.json

* Fix tests

* Adjust docstring
2022-09-27 15:34:00 +01:00
Erik Montnemery
5bcef1c7ce
Indicate in statistics issues when units can be converted () 2022-09-27 13:51:38 +02:00
epenet
c1bc26b413
Finish migration of recorder to unit conversion () 2022-09-25 21:14:18 -04:00
epenet
ddf56baf7a
Move temperature utility to unit_conversion () 2022-09-22 18:31:50 +02:00
epenet
c8491c4404
Move volume utility to unit_conversion ()
* Move volume utility to unit_conversion

* Split tests
2022-09-22 17:49:45 +02:00
epenet
523d8d246b
Move pressure utility to unit_conversion () 2022-09-22 16:44:09 +02:00
epenet
0767cdd935
Move energy and power utilites to unit_conversion ()
* Move energy and power utilites to unit_conversion

* Move tests
2022-09-22 15:39:49 +02:00
epenet
6002377d4f
Convert UnitConverter protocol to a class ()
* Convert UnitConverter protocl to a class

* Remove logic change

* Use TypeVar

* Remove NORMALIZED_UNIT from pressure

* Reduce size of PR

* Reduce some more

* Once more

* Once more

* Remove DEVICE_CLASS
2022-09-22 14:15:22 +02:00
epenet
713fb874a8
Add NORMALISED_UNIT to UnitConverter ()
* Add NORMALISED_UNIT to UnitConverter

* Adjust statistics

* Rename
2022-09-22 08:50:08 +02:00
epenet
ca78b1a77d
Add new energy utility ()
* Add new energy utility

* Adjust STATISTIC_UNIT_TO_VALID_UNITS
2022-09-21 19:40:40 +02:00