Commit Graph

45 Commits (c896458fcf75102c88ecc90ffa61a7b9f632336e)

Author SHA1 Message Date
Joakim Plate 30e11ed068
Update links between config entry and device on sensor change in integral (#119213) 2024-06-09 18:26:33 +02:00
Ron Weikamp 43c69c71c2
Add time based integration trigger to Riemann sum integral helper sensor (#110685)
* Schedule max dt for Riemann Integral sensor

* Simplify validation. Dont integrate on change if either old or new state is not numeric.

* Add validation to integration methods. Rollback requirement for both states to be always numeric.

* Use 0 max_dt for disabling time based updates.

* Use docstring instead of pass keyword in abstract methods.

* Use time_period config validation for max_dt

* Use new_state for scheduling max_dt. Only schedule if new state is numeric.

* Use default 0 (None) for max_dt.

* Rename max_dt to max_age.

* Rollback accidental renaming of different file

* Remove unnecessary and nonsensical max value.

* Improve new config description

* Use DurationSelector in config flow

* Rename new config to max_sub_interval

* Simplify by checking once for the integration strategy

* Use positive time period validation of sub interval in platform schema

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Remove return keyword

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Simplify scheduling of interval exceeded callback

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Improve documentation

* Be more clear about when time based integration is disabled.

* Update homeassistant/components/integration/config_flow.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-30 20:40:23 +02:00
Joakim Plate 2b6dd59cfc
Allow reconfiguration of integration sensor (#116740)
* Allow reconfiguration of integration sensor

* Adjust allowed options to not change unit
2024-05-06 21:03:46 +02:00
Joost Lekkerkerker 906d3198e3
Use is in enum comparison in config flow tests F-J (#114670)
* Use right enum expression F-J

* Fix
2024-04-02 23:01:37 +02:00
Erik Montnemery 0030c97f59
Tweak integration sensor (#114384)
* Tweak integration sensor

* Improve tests
2024-04-02 09:19:25 +02:00
Ron Weikamp e1036b3af0
Refactor Riemann sum integral sensor to prepare for time based trigger (#113932)
* Refactor Integration sensor.

* Use local simple function to verify the State is numeric.

* Merge two methods to one.

* Method renaming: _handle_state_change

* Move async_write_ha_state to the caller.

* Add comment on why attr_icon is set to None

* Remove possible None type of State in validation methods.

* Use a dict to map method name to method class.

* Explain derived unit after integration.

* Renaming to _multiply_unit_with_time and elaborate in docstring.

* Set integral unit_of_measurement explicitly to None if source unit_of_measurement is None

* One function for unit of measurement related steps.

* Improve docstring of _multiply_unit_with_time

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply f-string suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Be more clear in comment about removing the sensors icon default.

* Apply suggestions from code review

Co-authored-by: Diogo Gomes <diogogomes@gmail.com>

* Update homeassistant/components/integration/sensor.py

* Update homeassistant/components/integration/sensor.py

* Update homeassistant/components/integration/sensor.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Diogo Gomes <diogogomes@gmail.com>
2024-03-26 19:09:48 +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 32f3f46542
Add empty line after module docstring (2) [tests.components] (#112737) 2024-03-08 19:16:21 +01:00
Marc Mueller c88b337600
Add empty line after module docstring [tests f-k] (#112709) 2024-03-08 14:50:04 +01:00
Jan-Philipp Benecke 92b3c0c96b
Update i-j* tests to use entity & device registry fixtures (#103900) 2023-11-13 11:51:55 +01:00
Robert Resch 1915fee9ba
Remove "none" in favor of optional select in integration (#101396) 2023-10-11 17:36:53 +02:00
Erik Montnemery 3e6c844048
Adjust integration tests which create devices (#98196) 2023-08-10 18:23:33 +02:00
dougiteixeira c6210b68bd
Fix device source for Riemann sum integral (#95622)
Fix Device Source
2023-06-30 14:49:00 -04:00
dougiteixeira e5afff7f98
Add the device of the source entity in the helper entities for Riemann sum integral (#94727) 2023-06-23 00:04:51 +02:00
Diogo Gomes b5f582eecc
Make Riemann sum sensors restore last valid state (#93674)
* keep last valid state

* keep last valid state

* typo

* increase coverage

* better error handling

* debug messages

* increase coverage

* remove random log

* don't expose last_valid_state as an attribute
2023-06-02 08:44:36 -04:00
J. Nick Koston 33c2cb9895
Fix integration trapezoidal test (#93494) 2023-05-24 15:24:15 -05:00
J. Nick Koston 70c1fe8c6c
Update integration tests to avoid patching utcnow (#93480) 2023-05-24 20:54:11 +02:00
Diogo Gomes e100bcfaea
Better handling of source sensor unavailability in Riemman Integration (#93137)
* refactor and increase coverage

* fix log order
2023-05-23 11:19:29 +02:00
Diogo Gomes 48546c77b5
Follow the unavailability of the source sensor (#91975) 2023-04-25 09:49:58 +02:00
Franck Nijhof 9030ca05b1
Enable Ruff SIM118 (#87772) 2023-02-15 12:39:12 +01:00
epenet 37a2040d7b
Add type hints to integration tests (h-i) (#87703) 2023-02-08 18:12:56 +01:00
epenet 59ca7780fa
Add typing to tests with single hass argument (#87631) 2023-02-07 15:01:16 +01:00
Michael e35ab75c0b
Replace the usage of unit constants by enumerations in Tests [h-l] (#85934) 2023-01-15 14:52:55 +01:00
Franck Nijhof 2e92fefc0a
Fix uom/device class mismatches in tests (#84372) 2022-12-21 22:47:59 +01:00
Franck Nijhof a6244eea28
Search/replace RESULT_TYPE_* by FlowResultType enum (#74656) 2022-07-07 21:28:18 +02:00
Erik Montnemery 78cb0e24bc
Improve integration sensor's time unit handling (#72759) 2022-05-31 15:51:38 +02:00
RoboMagus c1ddde3764
Check if attributes are present in new_state before accessing them (#71967)
* Check if attributes are present in new_state before accessing them.

* Early return if new state is None|Unknown|Unavailable

* Removed whitespace at line endings. +black run

* Update test for coverage
2022-05-25 08:44:08 +02:00
Diogo Gomes fa28ee1f14
Remove deprecated unit configuration option from integration integration (#69157) 2022-04-13 19:19:34 +02:00
Erik Montnemery 0655ebbd84
Add config flow for integration sensor (#68288) 2022-03-18 09:52:17 +01:00
Ryan Steckler b541e91885
Fix units not being pulled from source sensor (#63639) 2022-01-24 15:15:34 +01:00
Dave T 498720f3c9
Use DeviceClass Enums in integration tests (#62511) 2021-12-21 19:03:39 +01:00
Diogo Gomes d705b35ea1
Address comment in integration Riemann sum PR #55875 (#55895)
* https://github.com/home-assistant/core/pull/55875\#discussion_r703334504

* missing test update
2021-09-07 19:40:20 +02:00
Diogo Gomes 1ca9deb520
Integration Sensor Initial State (#55875)
* initial state is UNAVAILABLE

* update tests
2021-09-07 08:12:54 +02:00
Erik Montnemery b1dbdec2ea
Set state class to total for Integration sensors (#55872) 2021-09-07 00:27:31 +02:00
Daniel Hjelseth Høyer 27849426fe
Remove last_reset attribute and set state class to total_increasing for Integration sensors (#54815) 2021-08-18 15:54:11 +02:00
Diogo Gomes b88f0adbe9
Restores unit_of_measurement (#54335) 2021-08-09 19:48:01 +02:00
Daniel Hjelseth Høyer 6590e464af
Integration. Add device class, last_reset, state_class (#53698)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-07-29 20:05:53 +02:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Paulus Schoutsen 2af984917e
Use asynctest-mock in most places (#35109)
* Use asynctest-mock in most places

* Fix broken patch in pilight
2020-05-03 11:27:19 -07:00
springstan f839ba00eb
Use POWER_WATT constant (#33984) 2020-04-11 15:40:59 +02:00
springstan 02c9e47db8
Use ENERGY_KILO_WATT_HOUR constant (#33962) 2020-04-10 20:21:29 +02:00
springstan a85808e325
Add and use time related constants (#32065)
* Add and use time related constants

* Sort time constants and reuse them in data rate constants

* Fix greeneyemonitor import

* Fix greeneyemonitor import V2

* Fix failing here_travel_time test

* Add TIME_MONTHS and TIME_YEARS

* Use TIME_MINUTES in opentherm_gw and isy994

* Add and use TIME_MILLISECONDS

* Change inconsistent ones

* Add TIME_MICROSECONDS and TIME_WEEKS

* Use constants in apcupsd and travisci

* Fix import error in upnp sensor.py

* Fix isy994 sensor.py using TIME_YEARS

* Fix dyson tests

* Use TIME_SECONDS in more places

* Use TIME_DAYS in google wifi
2020-02-23 22:09:24 +02:00
Paulus Schoutsen 00521b5e80
Fix flaky integration test (#27905) 2019-10-18 20:57:54 -07:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Penny Wood f195ecca4b Consolidate all platforms that have tests (#22109)
* Moved climate components with tests into platform dirs.

* Updated tests from climate component.

* Moved binary_sensor components with tests into platform dirs.

* Updated tests from binary_sensor component.

* Moved calendar components with tests into platform dirs.

* Updated tests from calendar component.

* Moved camera components with tests into platform dirs.

* Updated tests from camera component.

* Moved cover components with tests into platform dirs.

* Updated tests from cover component.

* Moved device_tracker components with tests into platform dirs.

* Updated tests from device_tracker component.

* Moved fan components with tests into platform dirs.

* Updated tests from fan component.

* Moved geo_location components with tests into platform dirs.

* Updated tests from geo_location component.

* Moved image_processing components with tests into platform dirs.

* Updated tests from image_processing component.

* Moved light components with tests into platform dirs.

* Updated tests from light component.

* Moved lock components with tests into platform dirs.

* Moved media_player components with tests into platform dirs.

* Updated tests from media_player component.

* Moved scene components with tests into platform dirs.

* Moved sensor components with tests into platform dirs.

* Updated tests from sensor component.

* Moved switch components with tests into platform dirs.

* Updated tests from sensor component.

* Moved vacuum components with tests into platform dirs.

* Updated tests from vacuum component.

* Moved weather components with tests into platform dirs.

* Fixed __init__.py files

* Fixes for stuff moved as part of this branch.

* Fix stuff needed to merge with balloob's branch.

* Formatting issues.

* Missing __init__.py files.

* Fix-ups

* Fixup

* Regenerated requirements.

* Linting errors fixed.

* Fixed more broken tests.

* Missing init files.

* Fix broken tests.

* More broken tests

* There seems to be a thread race condition.
I suspect the logger stuff is running in another thread, which means waiting until the aio loop is done is missing the log messages.
Used sleep instead because that allows the logger thread to run. I think the api_streams sensor might not be thread safe.

* Disabled tests, will remove sensor in #22147

* Updated coverage and codeowners.
2019-03-18 23:07:39 -07:00