Commit graph

64 commits

Author SHA1 Message Date
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
Marc Mueller
8f1e2f1a7b
Replace EventType with Event [h-i] (#112740) 2024-03-08 19:35:47 +01:00
Marc Mueller
8809d3aa88
Add empty line after module docstring [g-i] (#112699) 2024-03-08 08:52:48 -05:00
Robert Resch
eab4c24f7f
Fix KeyError in derivative and integration (#102294) 2023-10-19 18:22:22 +02:00
Robert Resch
1915fee9ba
Remove "none" in favor of optional select in integration (#101396) 2023-10-11 17:36:53 +02:00
Erik Montnemery
d1afcd773f
Revert "Cache entity properties that are never expected to change in the base class" (#100422)
Revert "Cache entity properties that are never expected to change in the base class (#95315)"

This reverts commit 042776ebb8.
2023-09-15 11:25:24 +02:00
J. Nick Koston
042776ebb8
Cache entity properties that are never expected to change in the base class (#95315) 2023-09-14 17:48:48 -05:00
Ville Skyttä
c287bd1a3b
Remove pylint configs flagged by useless-suppression (#99081) 2023-08-26 17:46:03 +03:00
Diogo Gomes
f96446cb24
Clean up integration sensor (#98552)
always update
2023-08-18 20:45:12 +02:00
Erik Montnemery
045c327928
Move DeviceInfo from entity to device registry (#98149)
* Move DeviceInfo from entity to device registry

* Update integrations
2023-08-10 22:04:26 -04:00
Marc Mueller
5b73bd2f8e
Use EventType for state changed [h-m] (#97117) 2023-07-24 08:01:50 +02:00
Marc Mueller
77f38e33e5
Import names from typing instead of typing_extensions [3.11] (#97065) 2023-07-22 17:03:44 -05: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
epenet
c475273145
Prevent SensorEntity and RestoreEntity inheritance (#88971) 2023-05-24 12:49:35 +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
23e24d75dc
Don't try to restore unavailable nor unknown states (#92825) 2023-05-09 22:22:06 +02:00
Diogo Gomes
48546c77b5
Follow the unavailability of the source sensor (#91975) 2023-04-25 09:49:58 +02:00
epenet
55a5e17cf2
Use UnitOfTime in integrations (h-s) (#84289) 2022-12-20 13:21:14 +01:00
epenet
4f963cfc64
Improve type hints in integration (#78345) 2022-09-13 22:45:25 +02:00
epenet
23090cb8a2
Improve entity type hints [i] (#77529) 2022-08-30 19:21:08 +02:00
Diogo Gomes
8ca5b5d4a4
Remove icon attribute if device class is set (#76161) 2022-08-04 19:36:37 +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
852eaa062c
update unit_of_measurement even if unit_of_measurement is known (#69699) 2022-04-30 02:16:05 +03:00
Diogo Gomes
fa28ee1f14
Remove deprecated unit configuration option from integration integration (#69157) 2022-04-13 19:19:34 +02:00
Diogo Gomes
8fe9e364e1
Update integration Riemann sum to use _attr* (#69769)
* move to _attr

* improve debug

* review comment

Co-authored-by: Shay Levy <levyshay1@gmail.com>

Co-authored-by: Shay Levy <levyshay1@gmail.com>
2022-04-10 20:09:33 +03:00
Erik Montnemery
c79b361927
Unsubscribe from listeners when removing integration sensor (#69235) 2022-04-04 11:09:38 +02:00
Diogo Gomes
0cbc29caca
Add unique_id through YAML to the integration component (#68435) 2022-03-20 22:48:11 +01:00
Erik Montnemery
0655ebbd84
Add config flow for integration sensor (#68288) 2022-03-18 09:52:17 +01:00
Franck Nijhof
fa09cf663e
Update black to 22.1.0 (#65788) 2022-02-05 14:19:37 +01:00
Ryan Steckler
b541e91885
Fix units not being pulled from source sensor (#63639) 2022-01-24 15:15:34 +01:00
epenet
178d2848f3
Add setup type hints [i-k] (#63444)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-05 12:14:13 +01:00
epenet
1692fab664
Use new enums in integration (#61803)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-14 18:32:33 +01:00
Diogo Gomes
ec9b5df7b3
Ignore None state in state_change_event (#59485) 2021-11-10 22:31:56 -08:00
Marc Mueller
a48ddcadd4
Use assignment expressions 31 (#58715) 2021-10-30 16:29:07 +02:00
Diogo Gomes
84140a547b
deprecated unit_of_measurement (#55876) 2021-09-08 16:33:53 +02: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
Diogo Gomes
34d54511e8
Integration Sensor unit of measurement overwrite (#55869) 2021-09-06 13:41:01 -07:00
Thomas Lovén
8d37fd08c7
Fix integration sensors sometimes not getting device_class or unit_of_measurement (#54802) 2021-08-18 08:59:31 -07: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
Erik Montnemery
2720ba2753
Move temperature conversions to sensor base class (4/8) (#54472)
* Move temperature conversions to entity base class (4/8)

* Fix litterrobot sensor

* Fix tests
2021-08-11 21:17:47 +02:00
Diogo Gomes
b88f0adbe9
Restores unit_of_measurement (#54335) 2021-08-09 19:48:01 +02:00
Marc Mueller
0815eede4b
Replace lists with tuples (2) (#53685) 2021-07-30 01:20:03 +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
Erik Montnemery
fdf97eaca3
Migrate integrations i-m to extend SensorEntity (#48213) 2021-03-22 19:59:03 +01:00
Erik Montnemery
af4d06b12e
Update integrations f-i to override extra_state_attributes() (#47757) 2021-03-11 16:57:47 +01:00