implemented conversion of temperature

This commit is contained in:
Johannes
2022-04-01 18:56:03 +02:00
parent 20a289eb52
commit a59c0e3ddc
4 changed files with 12 additions and 4 deletions

View File

@@ -43,6 +43,13 @@ def rgb_dec565(rgb_color):
# and shift them to make them a 16 bit dec value in 565 format.
return ((int(red / 255 * 31) << 11) | (int(green / 255 * 63) << 5) | (int(blue / 255 * 31)))
def convert_temperature_from_celsius(c, unit):
if unit == "celsius":
temp = (c * 1.8) + 32
return f"{temp}°F"
else:
return f"{temp}°C"
def get_attr_safe(entity, attr, default):
res = entity.attributes.get(attr, default)
if res is None: