Commit Graph

705 Commits (dev)

Author SHA1 Message Date
Abílio Costa 0cce4d1b81
Test all device classes in Sensor device condition/trigger tests (#146366) 2025-06-09 14:22:58 +01:00
epenet de4a5fa30b
Remove unnecessary DOMAIN alias in tests (s-z) (#146010) 2025-06-02 08:48:37 +02:00
epenet c3ade400fb
Use Platform constant in tests (#145801)
* Use Platform constant in tests

* spelling

* Fix platform
2025-05-28 15:51:37 +02:00
Abílio Costa b626204f63
Add default device class display precision for Sensor (#145013)
* Add default device class display precision for Sensor

* Renaming, docstrings, cleanup

* Simplify units list

* Fix tests

* Fix missing precision when suggested is specified

* Update snapshots

* Fix when unit of measurement is not valid

* Fix tests

* Fix deprecated unit usage

* Fix goalzero tests

The sensor native_value method was accessing the data dict and trowing,
since the mock did not have any data for the sensors.

Since now the precision is always specified (it was missing for those
sensors), the throw was hitting async_update_entity_options in _update_suggested_precision.
Previously, async_update_entity_options was not called since it had no
precision.

* Fix metoffice

* Fix smartthings

* Add default sensor data for Tesla Wall Connector tests

* Update snapshots

* Revert spaces

* Update smartthings snapshots

* Add missing sensor mock for tesla wall connector

* Address review comments

* Add doc comment

* Add cap to doc comment

* Update comment

* Update snapshots

* Update comment
2025-05-26 19:40:29 +02:00
Abílio Costa 54dce53628
Add sensor tests for device class enums (#145523) 2025-05-26 14:28:30 +01:00
alorente 1d47dc41c9
Add reactive energy device class and units (#143941) 2025-05-15 12:05:46 +01:00
Robert Resch 64e1735647
Fix circular mean by always storing and using the weighted one (#142208)
* Fix circular mean by always storing and using the weighted one

* fix

* Fix test
2025-04-04 21:19:15 +02:00
Robert Resch f842640249
Add check that sensor state classes are used only with valid unit of measurements (#141444) 2025-03-26 13:52:00 +01:00
Robert Resch e3f2f30395
Add circular mean statistics and sensor state class MEASUREMENT_ANGLE (#138453)
* Add circular mean statistics

* fixes

* Add has_circular_mean and fix tests

* Fix mypy

* Rename to MEASUREMENT_ANGLE

* Fix kitchen_sink tests

* Fix sensor tests

* for testing only

* Revert ws command change

* Apply suggestions

* test only

* add custom handling for postgres

* fix recursion limit

* Check if column is already available

* Set default false and not nullable for has_circular_mean

* Proper fix to be backwards compatible

* Fix value is None

* Align with schema

* Remove has_circular_mean from test schemas as it's not required anymore

* fix wrong column type

* Use correct variable to reduce stats

* Add guard that the uom is matching a valid one from the state class

* Add some tests

* Fix tests again

* Use mean_type in StatisticsMetato difference between different mean type algorithms

* Fix leftovers

* Fix kitchen_sink tests

* Fix postgres

* Add circular mean test

* Add mean_type_changed stats issue

* Align the attributes with unit_changed

* Fix mean_type_change stats issue

* Add missing sensor recorder tests

* Add test_statistic_during_period_circular_mean

* Add mean_weight

* Add test_statistic_during_period_hole_circular_mean

* Use seperate migration step to null has_mean

* Typo ARITHMETIC

* Implement requested changes

* Implement requested changes

* Split into #141444

* Add StatisticMeanType.NONE and forbid that mean_type can be None

* Fix mean_type

* Implement requested changes

* Small leftover of latest StatisticMeanType changes
2025-03-26 13:15:58 +01:00
Robert Resch 65c05d66c0
Use a constant for sensor statistics issues (#141441) 2025-03-26 09:43:09 +01:00
Erik Montnemery 427aa55789
Correct fallback to state in state machine when processing statistics (#140396) 2025-03-13 09:28:15 +01:00
Erik Montnemery 51c09c2aa4
Add test fixture ignore_translations_for_mock_domains (#139235)
* Add test fixture ignore_translations_for_mock_domains

* Fix fixture

* Avoid unnecessary attempt to get integration

* Really fix fixture

* Add forgotten parameter

* Address review comment
2025-02-25 20:10:29 +01:00
Erik Montnemery 428cc1a951
Update signature of platforms' async_setup_entry in tests (#138271) 2025-02-11 13:17:39 +01:00
epenet 0e263aa427
Standardize homeassistant imports in full-CI tests (#136735) 2025-01-28 13:10:20 -05:00
Marc Mueller f822fd82bb
Fix recorder fixture typing (#136174) 2025-01-21 18:18:05 -10:00
Joost Lekkerkerker 53ad02a1eb
Enable RUF032 (#135836) 2025-01-20 08:05:33 +01:00
Joost Lekkerkerker 8a35261fd8
Remove unused noqas (#135583) 2025-01-15 10:02:18 +01:00
G Johansson 64752af4c2
Change minimum SQLite version to 3.40.1 (#135042)
Co-authored-by: J. Nick Koston <nick@koston.org>
2025-01-08 16:34:36 -10:00
Stefan Agner 962f1bad32
Add mW as unit of measurement for Matter electrical power sensors (#133504) 2024-12-19 11:40:05 +00:00
Abílio Costa 6db8fced60
Update buienradar sensors only after being added to HA (#131830)
* Update buienradar sensors only after being added to HA

* Move check to util

* Check for platform in sensor state property

* Move check to unit translation key property

* Add test for sensor check

* Properly handle added_to_hass

* Remove redundant comment
2024-12-02 13:52:59 +01:00
Robert Resch 1f9ecfe839
Remove deprecated sensor constants (#131843) 2024-11-28 20:49:49 +01:00
Robert Resch a67045ee6c
Remove deprecated home assistant const constants (#131799) 2024-11-28 12:12:37 +01:00
Abílio Costa e4e9d76b45
Raise error if sensor has translated and hardcoded unit (#131657) 2024-11-27 17:45:53 +01:00
Abílio Costa d8dd6a99b3
Use default translation on SensorEntity unit_of_measurement (#131633)
* Use translations on SensorEntity unit_of_measurement property

* Use default language for unit translation

* Update brother integration snapshot

* Update snapshots
2024-11-27 14:45:53 +01:00
Michael Arthur d8549409f7
Area units and conversion between metric and US (#123563)
* area conversions

* start work on tests

* add number device class

* update unit conversions to utilise distance constants

* add area unit

* update test unit system

* update device condition and trigger

* update statistic unit converters

* further tests work WIP

* update test unit system

* add missing string translations

* fix websocket tests

* add deprecated notice

* add more missing strings and missing initialisation of unit system

* adjust icon and remove strings from scrape and random

* Fix acre to meters conversion

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

* Tidy up valid units

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

* fix ordering of area

* update order alphabetically

* fix broken test

* update test_init

* Update homeassistant/const.py

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

* remove deprecated unit and fix alphabetical order

* change deprecation and add tests, change to millimeter conversion for inches

* fix order

* re-order defs alphabetically

* add measurement as well

* update icons

* fix up Deprecation of area square meters

* Update core integrations to UnitOfArea

* update test recorder tests

* unit system tests in alphabetical

* update snapshot

* rebuild

* revert alphabetization of functions

* other revert of alphabetical order

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2024-11-21 16:10:44 +01:00
epenet 3c3a6dff04
Add translation checks for issue registry (#130593) 2024-11-15 15:05:04 +01:00
Jakob Schlyter cd11f01ace
Add support for MW/GW/TW and GWh/TWh (#130089) 2024-11-08 22:12:16 +01:00
Erik Montnemery c87415023c
Correct cleanup of sensor statistics repairs (#127826) 2024-10-08 09:39:21 +02:00
Erik Montnemery 6d65d6bcf6
Don't create statistics issues when sensor is unavailable or unknown (#127226) 2024-10-01 22:08:48 +02:00
Erik Montnemery 495faf5033
Improve statistics issue title (#126851) 2024-09-27 18:32:20 +02:00
epenet 94efd3e230
Cleanup sensor tests (#126881) 2024-09-27 13:43:24 +02:00
Erik Montnemery 771575cfc5
Make statistics validation create issue registry issues (#122595)
* Make statistics validation create issue registry issues

* Disable creating issue about outdated MariaDB version in tests

* Use call_soon_threadsafe instead of run_callback_threadsafe

* Update tests

* Fix flapping test

* Disable creating issue about outdated SQLite version in tests

* Implement agreed changes

* Add translation strings for issue titles

* Update test
2024-09-25 11:11:11 +02:00
Trevor Schirmer 96b7fc9a75
Add mm/s and in/s As Unit Of Speed (#125044)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-22 09:01:46 -05:00
Christian Neumeier 3e53cc175f
Change POWER_VOLT_AMPERE_REACTIVE to UnitOfReactivePower (#117153)
* Refactoring: exchange POWER_VOLT_AMPERE_REACTIVE with UnitOfReactivePower

* updated iotawatt and mysensors from VOLT_AMPERE_REACTIVE to UnitOfReactivePower.VOLT_AMPERE_REACTIVE

* deprecation period for POWER_VOLT_AMPERE_REACTIVE changed to one year.

* POWER_VOLT_AMPERE_REACTIVE changed to UnitOfReactivePower in blebox integration

* Update homeassistant/const.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-08-21 15:36:45 +02:00
epenet f66b539027
Add missing hass type hint in component tests (s) (#124272) 2024-08-20 12:53:29 +02:00
Erik Montnemery ce2ffde22e
Update sensor recorder tests to async (#124061) 2024-08-18 13:20:58 -05:00
epenet 177690bcb3
Rename variable in sensor tests (#122954) 2024-07-31 20:42:05 +02:00
Erik Montnemery ec957e4a94
Run statistics on 5-minute intervals in tests (#122592)
* Run statistics on 5-minute intervals in tests

* Fix test failing when mysql does not return rows in insert order
2024-07-25 17:32:49 +02:00
Erik Montnemery c12a79ecba
Deduplicate sensor recorder tests (#122516) 2024-07-25 12:31:11 +02:00
Richard Kroegel 865190f0b0
Get suggested_unit_of_measurement via unit converter's UNIT_CLASS (#119196)
Co-authored-by: Richard <rikroe@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-07-10 17:45:07 +02:00
Erik Montnemery 5029da6919
Make the async_setup_recorder_instance fixture a context manager (#121086) 2024-07-03 14:05:34 -05:00
epenet 22f5f59478
Use service_calls fixture in core platform tests [m-z] (#121001) 2024-07-02 12:34:11 +02:00
Marc Mueller f11b316dac
Import Generator from collections.abc (4) (#120917) 2024-07-01 11:54:42 +02:00
Joost Lekkerkerker 0fdf037ba0
Fix ruff type comparison E721 (#120731)
Fix E721
2024-06-28 11:56:49 +02:00
G Johansson b59e7ede9a
Raise on incorrect suggested unit for sensor (#120180) 2024-06-22 22:05:45 +02:00
dontinelli 0dd5391cd7
Add Siemes and Millisiemens as additional units of conductivity and enable conversion between conductivity units (#118728) 2024-06-21 11:10:15 +02:00
epenet 0f0c2f0553
Fix redefined-argument-from-local pylint warning in tests (#119475) 2024-06-12 17:58:58 +02:00
epenet 4962895f19
Fix consider-using-enumerate warnings in tests (#119506) 2024-06-12 16:27:56 +02:00
epenet abb8c58b87
Fix consider-using-tuple pylint warnings in core tests (#119463) 2024-06-12 12:35:01 +02:00
epenet 2e3c3789d3
Use relative imports in tests [s-z] (#119283) 2024-06-10 13:33:15 +02:00