Commit graph

3432 commits

Author SHA1 Message Date
Erik Montnemery
fa0d68b1d7
Add NumberDeviceClass.DURATION (#96932) 2023-07-20 11:10:03 +02:00
Joost Lekkerkerker
a8e92bfcb6
Fix typo for PM 1 (#96473) 2023-07-17 09:22:07 +02:00
J. Nick Koston
260e00ffb4
Check the registry entry in sensor unit_of_measurement instead of unique_id (#96731)
The unit_of_measurement check was checking to see if the entity has
a unique_id instead of a registry entry. Its much cheaper to check
for the registry_entry than the unique id since some entity have
to construct it every time its read
2023-07-17 08:50:06 +02:00
Erik Montnemery
86a397720f
Move platform_integration_no_support issue to the homeassistant integration (#95927)
* Move platform_integration_no_support issue to the homeassistant integration

* Update test

* Improve repair text

* Update test
2023-07-07 13:31:54 +02:00
J. Nick Koston
3f9d5a0192
Use the converter factory in sensor.recorder._normalize_states (#95785)
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
b24c6adc75
Avoid regex for negative zero check in sensor (#95691)
* Avoid regex for negative zero check in sensor

We can avoid calling the regex for every sensor value
since most of the time values are not negative zero

* tweak

* tweak

* Apply suggestions from code review

* simpler

* cover

* safer and still fast

* safer and still fast

* prep for py3.11

* fix check

* add missing cover

* more coverage

* coverage

* coverage
2023-07-02 21:53:50 -04:00
Erik Montnemery
3c015f85f4
Revert "Change the device class name volatile organic compounds parts to VOCs ratio" (#95332) 2023-06-27 12:28:31 +02:00
dougiteixeira
363dab7ce4
Change the device class name volatile organic compounds parts to VOCs ratio (#95126) 2023-06-27 08:33:11 +02:00
Erik Montnemery
b71e0302d6
Use entity registry id in sensor device conditions (#95260) 2023-06-26 21:20:40 +02:00
Erik Montnemery
5884afd485
Teach sensor device trigger about entity registry ids (#94988) 2023-06-22 11:13:54 +02:00
Erik Montnemery
446a820cbb
Name unnamed sensors by their device class (#94646) 2023-06-20 23:09:24 +02:00
J. Nick Koston
584967a35a
Avoid double call to self.suggested_unit_of_measurement in sensor unit_of_measurement (#94582) 2023-06-14 21:33:05 -04:00
G Johansson
c6feb30c31
Raise issue "does not support platform setup" (#93585)
* Raise issue on platform missing

* Modify issue

* Remove deprecation

* Fix strings

* Strings

* Last strings

* strings to common
2023-05-28 21:53:32 +02:00
Erik Montnemery
d62cdf3d65
Improve error message for sensors with a non-numeric value (#93399)
* Improve error message for sensors with a non-numeric value

* Address review comment
2023-05-23 15:54:24 +02:00
J. Nick Koston
90984c34a9
Fix double call to options in sensor state (#93311) 2023-05-21 15:42:19 +03:00
Erik Montnemery
9a70f47049
Teach UnitlessRatioConverter about ppm and ppb (#92989) 2023-05-12 16:46:37 +02:00
Erik Montnemery
5a7c3aaa2d
Add sensor device class volatile_organic_compounds_parts (#92973) 2023-05-12 14:37:54 +02:00
Erik Montnemery
7546e8efa4
Remove stale comment from sensor.const (#92974) 2023-05-12 14:34:29 +02:00
J. Nick Koston
bb4c03ce3c
Avoid returning statistics columns that the metadata knows are impossible (#92095) 2023-04-30 20:46:26 +02:00
Franck Nijhof
ce16d8eeac
Rename Particulate matter sensors to PM (#91384) 2023-04-14 09:43:15 +02:00
Raman Gupta
bfea1367a7
Add ms to units comment for duration sensor device class (#90757) 2023-04-04 12:42:33 +02:00
Maciej Bieniek
2229a63acd
Fix default sensor entity name for PM1 (#90684)
Fix PM1 text
2023-04-02 20:53:00 -04:00
epenet
ab699d17a5
Ensure numeric sensors have a valid value (#85605)
* Ensure numeric sensors have a valid value

* Flake8
2023-03-31 14:12:51 +02:00
epenet
3599515325
Add missing strings to sensor integration (#90475)
* Add missing strings to sensor integration

* Enumeration

* Apply suggestion

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

---------

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2023-03-30 10:21:11 +02:00
Erik Montnemery
e22618a555
Write protect entity options (#90185) 2023-03-28 22:56:51 +02:00
Raman Gupta
16028dc9bc
Add milliseconds as valid duration sensor unit (#90018) 2023-03-26 23:52:01 +02:00
J. Nick Koston
88ad97f112
Fix generating statistics for time periods smaller than we can measure (#90069)
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 (#89960)
* 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
Franck Nijhof
cd3819abec
Add state attribute translations for Sensor (#89896) 2023-03-17 20:32:52 -04:00
J. Nick Koston
f6f3565796
Reduce latency to find stats metadata (#89824) 2023-03-16 19:00:02 -10:00
Franck Nijhof
f9919bb7cf
Add pre-defined entity name translations (#89792) 2023-03-16 21:10:20 +01:00
Franck Nijhof
f32b7859b8
Restructure translations for entity components (#89702) 2023-03-16 12:16:08 +01:00
J. Nick Koston
a6d6807dd0
Add typing to statistics results (#89118) 2023-03-14 09:06:56 -10:00
Jan Bouwhuis
8968ed1c47
Fix check on non numeric custom sensor device classes (#89052)
* Custom device classes are not numeric

* Update homeassistant/components/sensor/__init__.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Add test

* Update homeassistant/components/sensor/__init__.py

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

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-03-02 14:20:26 -05:00
Erik Montnemery
fca5cc6ea3
Add number + sensor device class volume storage (#88312)
* Add number + sensor device class volume storage

* Fix typo

* Format code

* Update device automations
2023-03-01 11:22:57 +01:00
Erik Montnemery
69ce6980d6
Add number + sensor device class energy storage (#88310)
* Add number + sensor device class energy storage

* Format code

* Update device automations
2023-02-28 19:35:43 +01:00
Erik Montnemery
390daf1723
Sort unit lists sent to frontend (#88898) 2023-02-28 16:12:49 +01:00
Erik Montnemery
fe8f3602ff
Fix sensor unit conversion bug (#88825)
* Fix sensor unit conversion bug

* Ensure the correct unit is stored in the entity registry
2023-02-27 11:46:55 +01:00
avee87
1519a78567
Fix log message in recorder on total_increasing reset (#88710) 2023-02-25 12:05:24 +01:00
epenet
488d78571e
Add missing device class triggers (#88316)
* Add constant tests for sensor device classes

* Add missing strings

* Adjust tests

* Add missing conditions

* Add missing trigger

* Cleanup
2023-02-20 08:30:51 +01:00
Erik Montnemery
f0b7343993
Change state class of weight sensors from total to measurement (#88314) 2023-02-18 13:26:53 +01:00
epenet
dfdd279add
Fix incorrect condition for atmospheric_pressure (#88320) 2023-02-17 14:00:32 +01:00
Gertjan
66ba0cb1d3
Fixed float number validation in sensor component (#88074) 2023-02-15 15:53:44 +01:00
epenet
ccf44d58cc
Expose DEVICE_CLASS_STATE_CLASSES sensor constant (#88172) 2023-02-15 14:48:27 +01:00
Erik Montnemery
8f2a764a43
Adjust suggested_display_precision according to unit conversion (#87614) 2023-02-13 13:55:12 +01:00
Erik Montnemery
3f910b49ae
Fix sensor unit conversion (#87978) 2023-02-13 10:08:07 +01:00
J. Nick Koston
b054296c42
Speed up selecting which statistics to compile (#87938) 2023-02-12 18:15:27 +01:00
J. Nick Koston
85649ec589
Reduce overhead to see if an entity is recorded (#87912)
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 (#87845)
* 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
Erik Montnemery
2d2ff19949
Round value in state_with_unit template function (#87619) 2023-02-09 12:54:59 +01:00