1
0
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:
Sebastian Rasor
2023-08-22 20:01:34 -05:00
committed by GitHub
parent 11ed2d5f18
commit b20bae23cc
2 changed files with 28 additions and 7 deletions

View File

@@ -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)")