Use unit enums in energy and sensor (#84343)

This commit is contained in:
epenet 2022-12-21 10:49:51 +01:00 committed by GitHub
parent 255f35b979
commit 9a488cf250
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 15 deletions

View file

@ -6,7 +6,7 @@ from typing import Any
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_UNIT_OF_MEASUREMENT,
TEMP_FAHRENHEIT,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.significant_change import (
@ -44,7 +44,7 @@ def async_check_significant_change(
absolute_change: float | None = None
percentage_change: float | None = None
if device_class == SensorDeviceClass.TEMPERATURE:
if new_attrs.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_FAHRENHEIT:
if new_attrs.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.FAHRENHEIT:
absolute_change = 1.0
else:
absolute_change = 0.5