Richard Kroegel
474a1a3d94
Use display_precision if suggested_display_precision is None ( #110270 )
...
Co-authored-by: Richard <rikroe@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-04-24 09:46:55 +02:00
Sid
9cbed10372
Enable Ruff PYI041 ( #115229 )
2024-04-08 09:29:05 -10:00
Jan-Philipp Benecke
22b14d83e8
Use `setup_test_component_platform` helper for sensor entity component tests instead of `hass.components` ( #114316 )
...
* Use `setup_test_component_platform` helper for sensor entity component tests instead of `hass.components`
* Missing file
* Fix import
* Remove invalid device class
2024-03-28 12:07:55 +01:00
Sid
00ec7f11f0
Enable Ruff rule PT007 ( #113764 )
...
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
Marc Mueller
7d6251ca08
Add empty line after module docstring [tests q-s] ( #112711 )
2024-03-08 14:47:22 +01:00
J. Nick Koston
d9addc45f9
Avoid scheduling a task to add each entity when not using update_before_add ( #110951 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-02-23 10:49:26 -10:00
Robert Resch
b409933d19
Add DurationConverter ( #108865 )
...
* Add DurationConverter
* Update withings snapshots
* Add sensor test
* Fix tests
* Update snapshots after #108902 was merged
2024-01-30 23:08:12 +01:00
Robert Resch
7d2c6a1bb6
Add check for valid initial_suggested_unit ( #108902 )
...
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-01-30 18:55:59 +01:00
Joakim Plate
cece117c93
Flow rate unit conversions and device class ( #106077 )
...
* Add volume flow rate conversions
* Add missing translations
* Adjust liter unit and add gallons per minute
* Adjust to min instead of m for minutes
* Add matching class for number
* Add some tests for number and sensor platform
* Add deprecated constants
* Add explicit list of flow rate for check
This reverts commit 105171af31
.
2024-01-30 15:01:08 +01:00
Jan-Philipp Benecke
80bfd4cef7
Raise ValueError when `last_reset` set and not `total` state class ( #108391 )
...
* Raise ValueError when last_reset set and not total state class
* Fix test
* Break long string into smaller ones
2024-01-29 20:21:35 +01:00
Erik Montnemery
c805ea7b4f
Include deprecated constants in wildcard imports ( #107114 )
2024-01-05 11:46:45 +01:00
Robert Resch
ebdf7b9c8c
Deprecate some deprecated const constants ( #106230 )
...
* Deprecate some deprecated const constants
* Improve code
* fix typing
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-12-23 20:18:51 +01:00
Robert Resch
d47ec91231
Deprecate deprecated sensor constants ( #106120 )
2023-12-21 00:02:20 +01:00
Jan Bouwhuis
a66c9bb7b6
Update stale doc strings in entity platform tests ( #105526 )
2023-12-12 08:28:08 +01:00
Robert Resch
f7292d5b00
Add check that sensors don't have EntityCategory.CONFIG set ( #101471 )
2023-10-09 13:37:52 +02:00
Erik Montnemery
17779c5f0c
Add loader.async_suggest_report_issue and loader.async_get_issue_tracker ( #101336 )
...
* Add loader.async_suggest_report_issue and loader.async_get_issue_tracker
* Update tests
* Add tests
* Address review comments
* Address review comments
2023-10-04 13:40:33 +02:00
Erik Montnemery
d0dc4d0963
Add missing device class to sensor.DEVICE_CLASS_UNITS ( #101256 )
2023-10-02 13:01:26 +02:00
Erik Montnemery
7a1ee98bb6
Fix handling of unit system change in sensor ( #100715 )
2023-09-23 13:28:14 +02:00
Erik Montnemery
bbcbb2e322
Improve Entity._suggest_report_issue ( #100204 )
2023-09-12 21:07:32 +02:00
Erik Montnemery
e3b945a8d0
Don't allow numerical sensor state to be NaN or inf ( #98110 )
2023-08-23 14:16:40 +02:00
Ville Skyttä
2399cd283a
Python 3.10 support cleanups ( #98640 )
2023-08-21 19:14:07 +02:00
Miguel Camba
38111141f9
Add new device class: PH (potential hydrogen) ( #95928 )
2023-07-23 18:49:10 +02: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
446a820cbb
Name unnamed sensors by their device class ( #94646 )
2023-06-20 23:09:24 +02:00
J. Nick Koston
fba826ae9e
Migrate restore_state helper to use registry loading pattern ( #93773 )
...
* Migrate restore_state helper to use registry loading pattern
As more entities have started using restore_state over time, it
has become a startup bottleneck as each entity being added is
creating a task to load restore state data that is already loaded
since it is a singleton
We now use the same pattern as the registry helpers
* fix refactoring error -- guess I am tired
* fixes
* fix tests
* fix more
* fix more
* fix zha tests
* fix zha tests
* comments
* fix error
* add missing coverage
* s/DATA_RESTORE_STATE_TASK/DATA_RESTORE_STATE/g
2023-05-30 20:48:17 -05: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
Erik Montnemery
5a7c3aaa2d
Add sensor device class volatile_organic_compounds_parts ( #92973 )
2023-05-12 14:37:54 +02: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
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
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
Franck Nijhof
d3ed8de232
Update Ruff to v0.0.247 ( #88210 )
...
* Update Ruff to v0.0.247
* Fix new found violations
2023-02-15 16:46:03 -05:00
epenet
80ee196fd8
Add type hints to integration tests (part 19) ( #88178 )
2023-02-15 18:07:40 +01:00
Gertjan
66ba0cb1d3
Fixed float number validation in sensor component ( #88074 )
2023-02-15 15:53:44 +01:00
Franck Nijhof
ed79265843
Enable Ruff PT006 ( #88165 )
...
* Enable Ruff PT006
* Adjust existing cases
* Fix tests
* Remove unneeded parentheses
2023-02-15 14:09:50 +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
epenet
4142f0d15d
Add return type to tests without arguments ( #87613 )
...
* Add return type to tests without arguments
* Black
* Cancel fixture amends
2023-02-07 14:20:06 +01:00
Erik Montnemery
bcc1aa03b4
Move sensor rounding to frontend ( #87330 )
...
* Move sensor rounding to frontend
* Update integrations
* Add comment
2023-02-04 14:54:36 -05:00
Franck Nijhof
bf482eee24
Extend state class sensor warnings with expected values ( #87294 )
2023-02-04 11:49:24 +01:00
Erik Montnemery
4d4fb2477d
Optionally update sensor units when unit system is changed ( #83851 )
2023-02-03 16:30:50 +01:00
Jan Bouwhuis
2e16b7e2df
Add numeric_state_expected property to Sensor class ( #87013 )
...
* Add is_numeric property to Sensor class
* Follw up comment
* Update homeassistant/components/sensor/__init__.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
* Update homeassistant/components/sensor/__init__.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
* Tests and corrections
* Simplify converion check
* Correct custom device class handling
* Update homeassistant/components/sensor/__init__.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
* rename to numeric_state_expected
* Replace with new const
* Adjust docstr
* Update homeassistant/components/sensor/__init__.py
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
* Move to const
* Correct logic
* Do not use bool
* Adjust docstr must be numeric
* remote state from docstr
* protect numeric_state_expected
* Use try_parse_enum for custom class check
* Remove redundant type hints
---------
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2023-02-01 18:45:13 +01:00
Erik Montnemery
d4489faa68
Drop minus sign on negative zero ( #86939 )
...
* Drop minus sign on negative zero
* Add tests
2023-01-30 08:31:27 -05:00
Franck Nijhof
e4a78420b8
Enable Ruff PT013 ( #86757 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-01-27 09:09:46 +01:00
Joakim Plate
1b97a51b5e
Print expected device class units in error log ( #86125 )
2023-01-25 20:45:50 +01:00
Erik Montnemery
086a6460ef
Allow customizing sensor state precision ( #86074 )
...
* Allow customizing sensor precision
* Don't convert integer strings to floats
* Tweak converting sensor state to number
* Drop default rounding to 2 decimals
* Adjust test
* Tweak rounding, improve test coverage
* Don't convert to a number if not necessary
* Raise if native_precision is set and state is not numeric
* Address review comments
* Address comments, simplify
* Don't call property twice
* Make exception more helpful
2023-01-25 08:55:46 +01:00
Franck Nijhof
0a367359f4
Add sensor state class validation for device classes ( #84402 )
...
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-01-16 14:31:24 +01:00
epenet
3179101fbc
Warn if numeric sensors have an invalid value ( #85863 )
...
Co-authored-by: mib1185 <mail@mib85.de>
2023-01-16 11:00:07 +01:00
Michael
9709391b52
Replace the usage of unit constants by enumerations in Tests [s-u] ( #85937 )
2023-01-16 09:00:27 +01:00
Erik Montnemery
b0d4b73874
Add unitless unit converter ( #85694 )
...
* Add unitless unit converter
* Adjust type hints
* Adjust tests
* Rename to UnitlessRatioConverter
2023-01-12 09:20:00 +01:00
epenet
9eb06fd59d
Simplify sensor state validation ( #85513 )
2023-01-10 11:52:29 +01:00