diff --git a/custom_components/norwegianweather/const.py b/custom_components/norwegianweather/const.py index 7f6adc0..828d9db 100644 --- a/custom_components/norwegianweather/const.py +++ b/custom_components/norwegianweather/const.py @@ -1,20 +1,28 @@ """Constants for NorwegianWeather.""" + +from homeassistant.components.sensor import ( + SensorDeviceClass, +) +from homeassistant.const import ( + UnitOfTime, + UnitOfVolumetricFlux, + UnitOfTemperature, + UnitOfPressure, + UnitOfLength, + UnitOfSpeed, + UnitOfLength, + UnitOfTime, + UnitOfSpeed, + UnitOfVolumetricFlux, +) + from homeassistant.const import ( - DEVICE_CLASS_TIMESTAMP, - LENGTH_CENTIMETERS, - TIME_HOURS, - SPEED_METERS_PER_SECOND, PERCENTAGE, - PRECIPITATION_MILLIMETERS_PER_HOUR, DEGREE, UV_INDEX, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_PRESSURE, - DEVICE_CLASS_TEMPERATURE, - TEMP_CELSIUS, - PRESSURE_HPA, ) + from .api import CONST_DIR_DEFAULT # Base component constants @@ -79,9 +87,10 @@ "wind_speed_bf_desc", "wind_speed_knot", ], - "units": SPEED_METERS_PER_SECOND, + "units": UnitOfSpeed.METERS_PER_SECOND, "convert_units_func": None, - "device_class": None, + # "device_class": None, + "device_class": SensorDeviceClass.WIND_SPEED, "icon": "mdi:weather-windy", "state_func": None, }, @@ -97,9 +106,10 @@ "wind_speed_bf_desc", "wind_speed_knot", ], - "units": SPEED_METERS_PER_SECOND, + "units": UnitOfSpeed.METERS_PER_SECOND, "convert_units_func": None, - "device_class": None, + # "device_class": None, + "device_class": SensorDeviceClass.WIND_SPEED, "icon": "mdi:weather-windy", "state_func": None, }, @@ -115,9 +125,11 @@ "wind_speed_bf_desc", "wind_speed_knot", ], - "units": None, + # "units": None, + "units": UnitOfSpeed.BEAUFORT, "convert_units_func": None, - "device_class": None, + # "device_class": None, + "device_class": SensorDeviceClass.WIND_SPEED, "icon": "mdi:weather-windy", "state_func": None, }, @@ -133,9 +145,9 @@ "wind_speed_bf_desc", "wind_speed_knot", ], + "device_class": None, "units": DEGREE, "convert_units_func": None, - "device_class": None, "icon": "mdi:windsock", "state_func": None, }, @@ -161,9 +173,11 @@ "type": "sensor", "key": "air_temperature", "attrs": ["dew_point_temperature", "relative_humidity"], - "units": TEMP_CELSIUS, + # "units": TEMP_CELSIUS, + "units": UnitOfTemperature.CELSIUS, "convert_units_func": None, - "device_class": DEVICE_CLASS_TEMPERATURE, + # "device_class": DEVICE_CLASS_TEMPERATURE, + "device_class": SensorDeviceClass.TEMPERATURE, "icon": None, "state_func": None, }, @@ -171,9 +185,11 @@ "type": "sensor", "key": "air_pressure_at_sea_level", "attrs": [], - "units": PRESSURE_HPA, + # "units": PRESSURE_HPA, + "units": UnitOfPressure.HPA, "convert_units_func": None, - "device_class": DEVICE_CLASS_PRESSURE, + # "device_class": DEVICE_CLASS_PRESSURE, + "device_class": SensorDeviceClass.PRESSURE, "icon": None, "state_func": None, }, @@ -196,9 +212,11 @@ "type": "sensor", "key": "dew_point_temperature", "attrs": ["air_temperature", "relative_humidity"], - "units": TEMP_CELSIUS, + # "units": TEMP_CELSIUS, + "units": UnitOfTemperature.CELSIUS, "convert_units_func": None, - "device_class": DEVICE_CLASS_TEMPERATURE, + # "device_class": DEVICE_CLASS_TEMPERATURE, + "device_class": SensorDeviceClass.TEMPERATURE, "icon": None, "state_func": None, }, @@ -218,7 +236,8 @@ "attrs": ["air_temperature", "dew_point_temperature"], "units": PERCENTAGE, "convert_units_func": None, - "device_class": DEVICE_CLASS_HUMIDITY, + # "device_class": DEVICE_CLASS_HUMIDITY, + "device_class": SensorDeviceClass.HUMIDITY, "icon": None, "state_func": None, }, @@ -241,9 +260,10 @@ "precipitation_amount_min", "probability_of_precipitation", ], - "units": PRECIPITATION_MILLIMETERS_PER_HOUR, + "units": UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR, "convert_units_func": None, - "device_class": None, + # "device_class": None, + "device_class": SensorDeviceClass.PRECIPITATION_INTENSITY, "icon": "mdi:weather-rainy", "state_func": None, },