Commit Graph

626 Commits (0458bd68d9aad50f5e21700eeb1ce4cb3cfaa511)

Author SHA1 Message Date
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
Erik Montnemery b5a6e6b9d5
Use real devices in sensor device condition tests (#102713) 2023-10-24 23:37:36 +02:00
Erik Montnemery 82cc62416e
Use real devices in sensor device trigger tests (#102695) 2023-10-24 22:37:44 +02:00
Robert Resch f7292d5b00
Add check that sensors don't have EntityCategory.CONFIG set (#101471) 2023-10-09 13:37:52 +02:00
J. Nick Koston c6ed022cce
Fix compiling missing statistics losing rows (#101616) 2023-10-08 19:43:00 +02:00
Erik Montnemery 775751ece5
Add WS command sensor/numeric_device_classes (#101257) 2023-10-06 10:27:45 +02:00
Erik Montnemery 659d437cac
Use loader.async_suggest_report_issue in sensor (#101389) 2023-10-05 20:07:56 +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
Ville Skyttä b51c0f6ddc
Remove unnnecessary pylint configs from components [s-z]* (#98925) 2023-08-24 01:25: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 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
Erik Montnemery eba04824a4
Replace assert_lists_same with pytest_unordered in integrations n-s (#94902) 2023-06-20 20:23:14 +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
Jan Bouwhuis ec98e22330
Add type hints for stub_blueprint_populate fixture (#93568)
Add typehints for stub_blueprint_populate fixture
2023-05-26 08:13:13 +02:00
Erik Montnemery 3cca338c6e
Improve blueprint test fixtures (#93519) 2023-05-25 13:45:19 +02:00
J. Nick Koston 7ec6e03d5d
Update sensor tests to avoid patching utcnow (#93497) 2023-05-24 19:54:08 -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
Erik Montnemery 4568207f9b
Support calculating changes between consecutive sum statistics (#92823)
* Support calculating changes between consecutive sum statistics

* Add support for unit conversion when calculating change

* Don't include sum in WS response unless requested

* Improve tests

* Break out calculating change to its own function

* Improve test coverage
2023-05-11 10:05:58 +02:00
Erik Montnemery 0126cfa9d9
Allow exposing any entity to the default conversation agent (#92398)
* Allow exposing any entity to the default conversation agent

* Tweak

* Fix race, update tests

* Update tests
2023-05-03 09:45:54 -04:00
J. Nick Koston 49079691d4
Reduce overhead of legacy database columns on new installs (#90246)
* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* not working as expected

* override the type compiler

* override the type compiler

* override the type compiler

* override the type compiler

* Apply suggestions from code review

* pgsql char1

* make entity filter test setup with old schema

* fix some more tests that were mutating state

* fix some more tests that were mutating state

* fix some more tests that were mutating state

* fix more dbstate mutations

* add shim for older tests

* split migration tests

* add coverage for purging legacy data

* tweak

* more fixes

* drop some legacy

* fix another test

* fix a few more

* add casts for postgresql in case someone deletes the schema changes table

* dry

* dry

* dry
2023-04-10 10:08:46 -04:00
J. Nick Koston d0d4ab6056
Require a list of entity ids when fetching history (#90992) 2023-04-08 16:14:44 -10:00
epenet 19ab76dad9
Fix lingering timers in sensor tests (#90856) 2023-04-05 19:52:30 +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
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
J. Nick Koston c41f91be89
Deduplicate entity_id in the states table (#89557) 2023-03-12 10:01:58 -10:00
Erik Montnemery cf7e500a8e
Support translating entity names (#88242) 2023-03-12 15:55:04 +01: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
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
Franck Nijhof 1e05697080
Enable Ruff B007 (#88356)
* Enable Ruff B007

* Adjust existing cases
2023-02-17 21:08:18 -05:00
Erik Montnemery 9989a4787b
Fix recorder platform tests (#88330) 2023-02-17 08:22:15 -06: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