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
Erik Montnemery
72c9ca2567
Update sensor test ( #85522 )
2023-01-09 14:26:52 +01:00
Franck Nijhof
f8fa676ac8
Do not validate device classes when entity state is unknown ( #84860 )
2022-12-30 13:07:49 -05:00
Franck Nijhof
c832982d94
Add sensor unit of measurement validation for device classes ( #84366 )
2022-12-21 16:14:11 +01:00
epenet
0c9a78fb8e
Use tuple in test parametrization ( #83379 )
2022-12-06 09:46:10 +01:00
Franck Nijhof
762eb57636
Validate state class and unit of measurement for non-numeric sensors ( #83344 )
...
* Validate state class and unit of measurement for non-numeric sensors
* Remove duration
* Fix rest tests
2022-12-06 00:07:02 +01:00
Erik Montnemery
67875b99a3
Refactor support for integrations to drop custom unit conversion ( #83228 )
...
* Refactor support for integrations to drop custom unit conversion
* Fix lying comment
* Address review comment
2022-12-05 16:12:37 +01:00
Franck Nijhof
ce00f093d6
Add enum device_class and state options property to sensor entities ( #82489 )
2022-12-02 09:11:15 +01:00
Erik Montnemery
b6586d5c34
Align number and sensor device classes ( #81909 )
...
* Align number and sensor device classes
* Add tests
* Tweak tests
2022-11-17 14:00:28 +01:00
Erik Montnemery
a4310d2085
Allow integrations to drop custom unit conversion ( #81005 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-10-26 15:11:28 -04:00
Erik Montnemery
352976fd1d
Add rules for converting volumes ( #80951 )
...
* Add rules for converting volumes
* Use SensorDeviceClass in new tests
* Tweak tests
* Update flo tests
* Update sensor tests
2022-10-26 10:29:33 +02:00
Erik Montnemery
6979cd95b0
Add suggested_unit_of_measurement attribute to sensors ( #80638 )
...
* Add suggested_unit_of_measurement attribute to sensors
* Lazy calculation of initial entity options
* Add type alias for entity options
* Small tweak
* Add tests
* Store suggested_unit_of_measurement in its own option key
* Adapt to renaming of IMPERIAL_SYSTEM
* Fix rebase mistakes
* Apply suggestions from code review
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-10-24 16:08:02 +02:00
epenet
e84e5f134e
Use US_CUSTOMARY_SYSTEM in tests ( #80658 )
...
* Use US_CUSTOMARY_SYSTEM in tests
* Don't update test_unit_system
2022-10-20 15:42:23 +02:00
epenet
5389ff3253
Add new weight device class ( #79185 )
2022-09-28 12:13:49 +02:00
epenet
12e4d18038
Add volume to SensorDeviceClass ( #77960 )
...
* 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 ( #77953 )
...
* 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 ( #77951 )
...
* 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
Franck Nijhof
7adb0f0ef5
Custom component -> Custom integration ( #75404 )
2022-07-18 22:10:22 +02:00
Erik Montnemery
baa810aabb
Improve warnings for datetime and date sensors with invalid states ( #73598 )
2022-06-17 12:17:13 +02:00
Diogo Gomes
03874d1b65
Correct state restoring for Utility Meter sensors ( #66851 )
...
* fix merge
* backward compatability
* add status
* increase coverage
* increase further the coverage
* adds support for Decimal in SensorExtraStoredData
* more precise
* review
* don't restore broken last_reset
* increase coverage
* address review comments
* stale
* coverage increase
* Update homeassistant/components/utility_meter/sensor.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* catch corrupt files and respective tests
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-04-19 09:01:52 +02:00
Erik Montnemery
e830032b33
Remove deprecated temperature conversion of non temperature sensors ( #69069 )
2022-04-04 20:02:40 +02:00
Erik Montnemery
87100c2517
Drop deprecated support for unit_of_measurement from sensor ( #69061 )
2022-04-01 08:22:19 -07:00
Erik Montnemery
9471e4d77c
Don't override temperature unit for sensors ( #68910 )
2022-03-30 10:15:00 -07:00
Erik Montnemery
91f6e58e9a
Allow customizing unit for temperature and pressure sensors ( #64366 )
...
* Allow customizing unit for temperature and pressure sensors
* pylint
* Adjust google_wifi tests
* Address review comments and add tests
* Improve rounding when scaling
* Tweak rounding
* Further tweak rounding
* Allow setting entity options with config/entity_registry/update
* Address review comments
* Tweak tests
* Load custom unit when sensor is added
* Override async_internal_added_to_hass
* Adjust tests after rebase
* Apply suggestions from code review
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Address review comments
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-03-30 15:43:04 +02:00
Erik Montnemery
009b31941a
Support restoring SensorEntity native_value ( #66068 )
2022-02-08 14:00:26 -08:00
Franck Nijhof
e242796394
Remove deprecated format for date(time) sensors ( #65734 )
2022-02-04 23:42:29 -08:00