Commit graph

13 commits

Author SHA1 Message Date
Jan Bouwhuis
2e16b7e2df
Add numeric_state_expected property to Sensor class (#87013)
* Add is_numeric property to Sensor class

* Follw up comment

* Update homeassistant/components/sensor/__init__.py

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

* Update homeassistant/components/sensor/__init__.py

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

* Tests and corrections

* Simplify converion check

* Correct custom device class handling

* Update homeassistant/components/sensor/__init__.py

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

* rename to numeric_state_expected

* Replace with new const

* Adjust docstr

* Update homeassistant/components/sensor/__init__.py

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

* Move to const

* Correct logic

* Do not use bool

* Adjust docstr must be numeric

* remote state from docstr

* protect numeric_state_expected

* Use try_parse_enum for custom class check

* Remove redundant type hints

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2023-02-01 18:45:13 +01:00
Franck Nijhof
1edd00c51f
Allow any state class when using the precipitation device class (#86977) 2023-01-30 22:43:23 +01:00
Franck Nijhof
7ed9967245
Fix state classes for duration device class (#86727) 2023-01-26 17:26:52 +01:00
SgtBatten
0ccab19d2c
Add Mega Joule as valid unit of energy (#86055)
* Add Mega joule

* Reorder valid energy types

Alphabetical

* Add Mega Joule

* Add Mega Joule as valid energy unit

* Add Mega Joule

* Add Mega Joule as a Unit of Measurement to Energy

* Update tests

* Update tests

* Update number docstring

Co-authored-by: Roving Ronin <108674933+Roving-Ronin@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-01-25 14:13:42 +01:00
Erik Montnemery
f327a247a0
Allow a temperature sensor to be in K (#86073) 2023-01-25 11:47:52 +01:00
Erik Montnemery
14a32cd63b
Allow converting units of additional sensor device classes (#86072) 2023-01-17 09:35:53 +01:00
Franck Nijhof
0a367359f4
Add sensor state class validation for device classes (#84402)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-01-16 14:31:24 +01:00
Erik Montnemery
b0d4b73874
Add unitless unit converter (#85694)
* Add unitless unit converter

* Adjust type hints

* Adjust tests

* Rename to UnitlessRatioConverter
2023-01-12 09:20:00 +01:00
Erik Montnemery
54168c9bdb
Allow converting units of energy sensors (#85497) 2023-01-09 12:26:35 +01:00
Erik Montnemery
c1075ebb8c
Allow SensorDeviceClass.POWER_FACTOR unit None (#85181) 2023-01-05 11:03:37 +01:00
Erik Montnemery
8a0fb21988
Clarify SensorDeviceClass.PRECIPITATION docstring (#85045) 2023-01-03 11:30:03 +01:00
Franck Nijhof
6ecf2e8c71
Move sensor constants and define public names from this module (#84973) 2023-01-02 16:00:50 +01:00
Matthias Alphart
cd0ae66d58
Add CONF_STATE_CLASS to sensor/__init__.py (#54106)
* add CONF_STATE_CLASS to const.py

* move to `sensor/__init__.py`

* move to sensor/const.py

* Revert "move to sensor/const.py"

This reverts commit 604d0d066b.

* move it to `sensor/const.py` but import it from `sensor/__init__.py`

* add Modbus
2021-08-27 05:54:50 +02:00