Skip to content

Commit

Permalink
Update to new device classes and unit constants
Browse files Browse the repository at this point in the history
  • Loading branch information
tmjo committed May 3, 2024
1 parent d51e600 commit 00a4217
Showing 1 changed file with 46 additions and 26 deletions.
72 changes: 46 additions & 26 deletions custom_components/norwegianweather/const.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -161,19 +173,23 @@
"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,
},
"weather_air_pressure": {
"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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand Down

0 comments on commit 00a4217

Please sign in to comment.