Commit Graph

23 Commits (b07e9df308a2fec26d76ee0ae046c5699d0546d1)

Author SHA1 Message Date
Jan-Philipp Benecke 81450f0117
Update d-e* tests to use entity & device registry fixtures (#103804) 2023-11-12 10:38:32 +01:00
Robert Resch 7db2fdd68c
Remove "none" in favor of optional select in derivate (#101312) 2023-10-11 17:36:15 +02:00
Erik Montnemery 57d0fd7bb1
Adjust derivative tests which create devices (#98186) 2023-08-10 18:25:28 +02:00
dougiteixeira 11146ff40b
Fix device source for Derivative (#95621)
Fix Device Source
2023-06-30 14:29:44 -04:00
dougiteixeira 403496eb92
Add the device of the source entity in the helper entities for Derivative (#94751)
* Adds the device of the original entity in the helper entities for Derivative

* Update

* Update
2023-06-26 18:06:25 +02:00
J. Nick Koston cff72f9653
Update derivative tests to avoid patching utcnow (#93477) 2023-05-24 20:54:50 +02:00
Erik Montnemery 9ab95b6348
Revert "Add `state_class = MEASUREMENT` to Derivative sensor (#88408)" (#88952) 2023-03-01 08:53:05 +01:00
Carlos Gustavo Sarmiento fa2e7aa592
Add `state_class = MEASUREMENT` to Derivative sensor (#88408)
* Add `state_class = MEASUREMENT` to Derivative sensor

One line change per title.

* Update sensor.py

* Update tests for Derivative Sensor
2023-02-20 21:57:58 +01:00
Franck Nijhof 9030ca05b1
Enable Ruff SIM118 (#87772) 2023-02-15 12:39:12 +01:00
epenet 3052de3e8e
Add type hints to integration tests (d-e) (#87699) 2023-02-08 13:01:44 +01:00
Michael 2850583085
Replace the usage of unit constants by enumerations in Tests [a-e] (#85932) 2023-01-15 14:44:01 +01:00
Franck Nijhof a6244eea28
Search/replace RESULT_TYPE_* by FlowResultType enum (#74656) 2022-07-07 21:28:18 +02:00
Erik Montnemery 5bb271c9fb
Add config flow for derivative sensor (#68268) 2022-03-18 12:14:38 +01:00
sophof 79d267f8d7
Fix derivative integration showing unexpected spikes (#65528) 2022-02-23 10:16:12 -08:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Joakim Plate ac551179ae
Fix flapping derivative tests where time would move between state changes (#43579) 2020-11-25 17:08:00 +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 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
Bas Nijholt 8498ca37cd
Fix moving average test for discrete derivative sensor (#31750)
* fix test_data_moving_average_for_discrete_sensor

After https://github.com/home-assistant/home-assistant/pull/31717 the test
didn't actually test anything anymore.

This fixes that.

* make the test faster
2020-02-12 09:53:06 -08:00
Paulus Schoutsen 6fcf5472a5
Limit derivative test (#31717) 2020-02-11 09:03:52 +01:00
Bas Nijholt 119566f280
Keep track of the derivative for unit_time (#31397)
* keep track of the derivative for unit_time

In this way, you will get a better estimate of the derivate during
the timescale that is relavant to the sensor.

This solved a problem where sensors have a low output resolution.
For example a temperature sensor that can only be integer numbers.

It might report many values that are the same and then suddenly go up one value.
Only in that moment (with the current implementation) the derivative will be finite.

With my proposed implementation, this problem will not occur, because it takes the average
derivative of the last `unit_time`.

* only loop as much as needed

* treat the special case of 1 entry

* add option time_window

* use cv.time_period

* fix comment

* set time_window=0 by default

* rephrase comment

* use timedelta for time_window

* fix the "G" unit_prefix and add more prefixes

https://en.wikipedia.org/wiki/Unit_prefix

* add debugging lines

* simplify logic

* fix bug where the there was a division of unit_time instead of multiplication

* simplify tests

* add test_data_moving_average_for_discrete_sensor

* fix test_dataSet6

* improve readability of the tests

* better explain the test

* remove debugging log lines
2020-02-03 14:22:47 -08:00
Faucogney Anthony b2212ad445 Add Derivative component (#26456)
* create derivation component

based on integration component
remove left and right

* Update test

(was'n saved)

* add some functionnal point test

* Change derivation to derivative

* Continue migration from derivation to derivative

* Add codeowners info

* fix tests typo and values

* Improve code from reviewer

add test case
fix test values
still a prefix issue that should not

* create derivation component

based on integration component
remove left and right

* Update test

(was'n saved)

* add some functionnal point test

* Change derivation to derivative

* Continue migration from derivation to derivative

* Add codeowners info

* fix tests typo and values

* Improve code from reviewer

add test case
fix test values
still a prefix issue that should not

* Update homeassistant/components/derivative/sensor.py

Fix test issue with unit of measurement

Co-Authored-By: Santobert <tobhaase@gmail.com>

* Fix review

Move ValueError to SyntaxError

* precise state test

* un comment original tests and remove error tests

* Fix isort issue

* Fix review

- update doc link
- migrate to general const import

* Rollback import conf_unit, just defined localy

Co-authored-by: Santobert <tobhaase@gmail.com>
2020-01-19 22:17:06 -08:00