mirror of
https://github.com/esphome/esphome.git
synced 2025-09-06 05:12:21 +01:00
Introduce cv.temperature_delta and fix problematic thermostat configuration behavior (#5297)
This commit is contained in:
@@ -929,6 +929,27 @@ def temperature(value):
|
||||
raise err
|
||||
|
||||
|
||||
def temperature_delta(value):
|
||||
err = None
|
||||
try:
|
||||
return _temperature_c(value)
|
||||
except Invalid as orig_err:
|
||||
err = orig_err
|
||||
|
||||
try:
|
||||
return _temperature_k(value)
|
||||
except Invalid:
|
||||
pass
|
||||
|
||||
try:
|
||||
fahrenheit = _temperature_f(value)
|
||||
return fahrenheit * (5 / 9)
|
||||
except Invalid:
|
||||
pass
|
||||
|
||||
raise err
|
||||
|
||||
|
||||
_color_temperature_mireds = float_with_unit("Color Temperature", r"(mireds|Mireds)")
|
||||
_color_temperature_kelvin = float_with_unit("Color Temperature", r"(K|Kelvin)")
|
||||
|
||||
|
Reference in New Issue
Block a user