mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 00:07:10 +00:00
Add and use length millimeters constant (#40116)
* Add and use length millimeters constant * Fix pylint error * Fix broken accuweather sensor test
This commit is contained in:
parent
511ea09c99
commit
06a133c3e9
@ -5,6 +5,7 @@ from homeassistant.const import (
|
||||
LENGTH_FEET,
|
||||
LENGTH_INCHES,
|
||||
LENGTH_METERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
SPEED_MILES_PER_HOUR,
|
||||
@ -24,7 +25,6 @@ ATTR_UNIT_METRIC = "Metric"
|
||||
CONCENTRATION_PARTS_PER_CUBIC_METER = f"p/{VOLUME_CUBIC_METERS}"
|
||||
COORDINATOR = "coordinator"
|
||||
DOMAIN = "accuweather"
|
||||
LENGTH_MILIMETERS = "mm"
|
||||
MANUFACTURER = "AccuWeather, Inc."
|
||||
NAME = "AccuWeather"
|
||||
UNDO_UPDATE_LISTENER = "undo_update_listener"
|
||||
@ -238,7 +238,7 @@ SENSOR_TYPES = {
|
||||
ATTR_DEVICE_CLASS: None,
|
||||
ATTR_ICON: "mdi:weather-rainy",
|
||||
ATTR_LABEL: "Precipitation",
|
||||
ATTR_UNIT_METRIC: LENGTH_MILIMETERS,
|
||||
ATTR_UNIT_METRIC: LENGTH_MILLIMETERS,
|
||||
ATTR_UNIT_IMPERIAL: LENGTH_INCHES,
|
||||
},
|
||||
"PressureTendency": {
|
||||
|
@ -21,6 +21,7 @@ from homeassistant.const import (
|
||||
CONF_NAME,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_METERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
PRESSURE_MBAR,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -71,7 +72,7 @@ SENSOR_TYPES = {
|
||||
"press_qnh": ["Pressure qnh", "qnh"],
|
||||
"press_msl": ["Pressure msl", "msl"],
|
||||
"press_tend": ["Pressure Tend", None],
|
||||
"rain_trace": ["Rain Today", "mm"],
|
||||
"rain_trace": ["Rain Today", LENGTH_MILLIMETERS],
|
||||
"rel_hum": ["Relative Humidity", PERCENTAGE],
|
||||
"sea_state": ["Sea State", None],
|
||||
"swell_dir_worded": ["Swell Direction", None],
|
||||
|
@ -30,6 +30,7 @@ from homeassistant.const import (
|
||||
DEGREE,
|
||||
IRRADIATION_WATTS_PER_SQUARE_METER,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
PRESSURE_HPA,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -82,22 +83,26 @@ SENSOR_TYPES = {
|
||||
"pressure": ["Pressure", PRESSURE_HPA, "mdi:gauge"],
|
||||
"visibility": ["Visibility", LENGTH_KILOMETERS, None],
|
||||
"windgust": ["Wind gust", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
||||
"precipitation": ["Precipitation", f"mm/{TIME_HOURS}", "mdi:weather-pouring"],
|
||||
"precipitation": [
|
||||
"Precipitation",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
"mdi:weather-pouring",
|
||||
],
|
||||
"irradiance": ["Irradiance", IRRADIATION_WATTS_PER_SQUARE_METER, "mdi:sunglasses"],
|
||||
"precipitation_forecast_average": [
|
||||
"Precipitation forecast average",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
"mdi:weather-pouring",
|
||||
],
|
||||
"precipitation_forecast_total": [
|
||||
"Precipitation forecast total",
|
||||
"mm",
|
||||
LENGTH_MILLIMETERS,
|
||||
"mdi:weather-pouring",
|
||||
],
|
||||
# new in json api (>1.0.0):
|
||||
"rainlast24hour": ["Rain last 24h", "mm", "mdi:weather-pouring"],
|
||||
"rainlast24hour": ["Rain last 24h", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
# new in json api (>1.0.0):
|
||||
"rainlasthour": ["Rain last hour", "mm", "mdi:weather-pouring"],
|
||||
"rainlasthour": ["Rain last hour", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"temperature_1d": ["Temperature 1d", TEMP_CELSIUS, "mdi:thermometer"],
|
||||
"temperature_2d": ["Temperature 2d", TEMP_CELSIUS, "mdi:thermometer"],
|
||||
"temperature_3d": ["Temperature 3d", TEMP_CELSIUS, "mdi:thermometer"],
|
||||
@ -108,23 +113,23 @@ SENSOR_TYPES = {
|
||||
"mintemp_3d": ["Minimum temperature 3d", TEMP_CELSIUS, "mdi:thermometer"],
|
||||
"mintemp_4d": ["Minimum temperature 4d", TEMP_CELSIUS, "mdi:thermometer"],
|
||||
"mintemp_5d": ["Minimum temperature 5d", TEMP_CELSIUS, "mdi:thermometer"],
|
||||
"rain_1d": ["Rain 1d", "mm", "mdi:weather-pouring"],
|
||||
"rain_2d": ["Rain 2d", "mm", "mdi:weather-pouring"],
|
||||
"rain_3d": ["Rain 3d", "mm", "mdi:weather-pouring"],
|
||||
"rain_4d": ["Rain 4d", "mm", "mdi:weather-pouring"],
|
||||
"rain_5d": ["Rain 5d", "mm", "mdi:weather-pouring"],
|
||||
"rain_1d": ["Rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"rain_2d": ["Rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"rain_3d": ["Rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"rain_4d": ["Rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"rain_5d": ["Rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
# new in json api (>1.0.0):
|
||||
"minrain_1d": ["Minimum rain 1d", "mm", "mdi:weather-pouring"],
|
||||
"minrain_2d": ["Minimum rain 2d", "mm", "mdi:weather-pouring"],
|
||||
"minrain_3d": ["Minimum rain 3d", "mm", "mdi:weather-pouring"],
|
||||
"minrain_4d": ["Minimum rain 4d", "mm", "mdi:weather-pouring"],
|
||||
"minrain_5d": ["Minimum rain 5d", "mm", "mdi:weather-pouring"],
|
||||
"minrain_1d": ["Minimum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"minrain_2d": ["Minimum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"minrain_3d": ["Minimum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"minrain_4d": ["Minimum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"minrain_5d": ["Minimum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
# new in json api (>1.0.0):
|
||||
"maxrain_1d": ["Maximum rain 1d", "mm", "mdi:weather-pouring"],
|
||||
"maxrain_2d": ["Maximum rain 2d", "mm", "mdi:weather-pouring"],
|
||||
"maxrain_3d": ["Maximum rain 3d", "mm", "mdi:weather-pouring"],
|
||||
"maxrain_4d": ["Maximum rain 4d", "mm", "mdi:weather-pouring"],
|
||||
"maxrain_5d": ["Maximum rain 5d", "mm", "mdi:weather-pouring"],
|
||||
"maxrain_1d": ["Maximum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"maxrain_2d": ["Maximum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"maxrain_3d": ["Maximum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"maxrain_4d": ["Maximum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"maxrain_5d": ["Maximum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"],
|
||||
"rainchance_1d": ["Rainchance 1d", PERCENTAGE, "mdi:weather-pouring"],
|
||||
"rainchance_2d": ["Rainchance 2d", PERCENTAGE, "mdi:weather-pouring"],
|
||||
"rainchance_3d": ["Rainchance 3d", PERCENTAGE, "mdi:weather-pouring"],
|
||||
|
@ -18,6 +18,7 @@ from homeassistant.const import (
|
||||
DEGREE,
|
||||
LENGTH_CENTIMETERS,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
PRESSURE_MBAR,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -110,11 +111,11 @@ SENSOR_TYPES = {
|
||||
],
|
||||
"precip_intensity": [
|
||||
"Precip Intensity",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
"in",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
"mdi:weather-rainy",
|
||||
["currently", "minutely", "hourly", "daily"],
|
||||
],
|
||||
@ -330,11 +331,11 @@ SENSOR_TYPES = {
|
||||
],
|
||||
"precip_intensity_max": [
|
||||
"Daily Max Precip Intensity",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
"in",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"mm/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
"mdi:thermometer",
|
||||
["daily"],
|
||||
],
|
||||
|
@ -9,6 +9,7 @@ from homeassistant.const import (
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENERGY_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
PRESSURE_HPA,
|
||||
@ -55,7 +56,7 @@ HM_UNIT_HA_CAST = {
|
||||
"AVERAGE_ILLUMINATION": "lx",
|
||||
"LOWEST_ILLUMINATION": "lx",
|
||||
"HIGHEST_ILLUMINATION": "lx",
|
||||
"RAIN_COUNTER": "mm",
|
||||
"RAIN_COUNTER": LENGTH_MILLIMETERS,
|
||||
"WIND_SPEED": SPEED_KILOMETERS_PER_HOUR,
|
||||
"WIND_DIRECTION": DEGREE,
|
||||
"WIND_DIRECTION_RANGE": DEGREE,
|
||||
|
@ -30,6 +30,7 @@ from homeassistant.const import (
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -367,7 +368,7 @@ class HomematicipTodayRainSensor(HomematicipGenericEntity):
|
||||
@property
|
||||
def unit_of_measurement(self) -> str:
|
||||
"""Return the unit this state is expressed in."""
|
||||
return "mm"
|
||||
return LENGTH_MILLIMETERS
|
||||
|
||||
|
||||
class HomematicipPassageDetectorDeltaCounter(HomematicipGenericEntity):
|
||||
|
@ -57,6 +57,7 @@ from homeassistant.const import (
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_METERS,
|
||||
LENGTH_MILES,
|
||||
LENGTH_MILLIMETERS,
|
||||
MASS_KILOGRAMS,
|
||||
MASS_POUNDS,
|
||||
PERCENTAGE,
|
||||
@ -361,7 +362,7 @@ UOM_FRIENDLY_NAME = {
|
||||
"43": "mV",
|
||||
"44": TIME_MINUTES,
|
||||
"45": TIME_MINUTES,
|
||||
"46": f"mm/{TIME_HOURS}",
|
||||
"46": f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
"47": TIME_MONTHS,
|
||||
"48": SPEED_MILES_PER_HOUR,
|
||||
"49": SPEED_METERS_PER_SECOND,
|
||||
@ -388,7 +389,7 @@ UOM_FRIENDLY_NAME = {
|
||||
"75": "weekday",
|
||||
"76": DEGREE,
|
||||
"77": TIME_YEARS,
|
||||
"82": "mm",
|
||||
"82": LENGTH_MILLIMETERS,
|
||||
"83": LENGTH_KILOMETERS,
|
||||
"85": "Ω",
|
||||
"86": "kΩ",
|
||||
@ -404,7 +405,7 @@ UOM_FRIENDLY_NAME = {
|
||||
"103": CURRENCY_DOLLAR,
|
||||
"104": CURRENCY_CENT,
|
||||
"105": LENGTH_INCHES,
|
||||
"106": f"mm/{TIME_DAYS}",
|
||||
"106": f"{LENGTH_MILLIMETERS}/{TIME_DAYS}",
|
||||
"107": "", # raw 1-byte unsigned value
|
||||
"108": "", # raw 2-byte unsigned value
|
||||
"109": "", # raw 3-byte unsigned value
|
||||
|
@ -4,6 +4,7 @@ from homeassistant.const import (
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_TIMESTAMP,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
PRESSURE_HPA,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -108,7 +109,7 @@ SENSOR_TYPES = {
|
||||
},
|
||||
"precipitation": {
|
||||
ENTITY_NAME: "Daily precipitation",
|
||||
ENTITY_UNIT: "mm",
|
||||
ENTITY_UNIT: LENGTH_MILLIMETERS,
|
||||
ENTITY_ICON: "mdi:cup-water",
|
||||
ENTITY_DEVICE_CLASS: None,
|
||||
ENTITY_ENABLE: True,
|
||||
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
PRESSURE_MBAR,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -52,9 +53,9 @@ SENSOR_TYPES = {
|
||||
"pressure": ["Pressure", PRESSURE_MBAR, None, DEVICE_CLASS_PRESSURE],
|
||||
"noise": ["Noise", "dB", "mdi:volume-high", None],
|
||||
"humidity": ["Humidity", PERCENTAGE, None, DEVICE_CLASS_HUMIDITY],
|
||||
"rain": ["Rain", "mm", "mdi:weather-rainy", None],
|
||||
"sum_rain_1": ["Rain last hour", "mm", "mdi:weather-rainy", None],
|
||||
"sum_rain_24": ["Rain last 24h", "mm", "mdi:weather-rainy", None],
|
||||
"rain": ["Rain", LENGTH_MILLIMETERS, "mdi:weather-rainy", None],
|
||||
"sum_rain_1": ["Rain last hour", LENGTH_MILLIMETERS, "mdi:weather-rainy", None],
|
||||
"sum_rain_24": ["Rain last 24h", LENGTH_MILLIMETERS, "mdi:weather-rainy", None],
|
||||
"battery_vp": ["Battery", "", "mdi:battery", None],
|
||||
"battery_lvl": ["Battery Level", "", "mdi:battery", None],
|
||||
"battery_percent": ["Battery Percent", PERCENTAGE, None, DEVICE_CLASS_BATTERY],
|
||||
|
@ -14,6 +14,7 @@ from homeassistant.const import (
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_TIMESTAMP,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
PRESSURE_PA,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
@ -112,8 +113,8 @@ WEATHER_SENSOR_TYPES = {
|
||||
SENSOR_DEVICE_CLASS: DEVICE_CLASS_PRESSURE,
|
||||
},
|
||||
ATTR_API_CLOUDS: {SENSOR_NAME: "Cloud coverage", SENSOR_UNIT: PERCENTAGE},
|
||||
ATTR_API_RAIN: {SENSOR_NAME: "Rain", SENSOR_UNIT: "mm"},
|
||||
ATTR_API_SNOW: {SENSOR_NAME: "Snow", SENSOR_UNIT: "mm"},
|
||||
ATTR_API_RAIN: {SENSOR_NAME: "Rain", SENSOR_UNIT: LENGTH_MILLIMETERS},
|
||||
ATTR_API_SNOW: {SENSOR_NAME: "Snow", SENSOR_UNIT: LENGTH_MILLIMETERS},
|
||||
ATTR_API_CONDITION: {SENSOR_NAME: "Condition"},
|
||||
ATTR_API_WEATHER_CODE: {SENSOR_NAME: "Weather Code"},
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ from homeassistant.const import (
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
@ -40,8 +41,13 @@ SENSOR_TYPES = {
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
],
|
||||
SENSOR_TYPE_HUMIDITY: ["Humidity", PERCENTAGE, None, DEVICE_CLASS_HUMIDITY],
|
||||
SENSOR_TYPE_RAINRATE: ["Rain rate", f"mm/{TIME_HOURS}", "mdi:water", None],
|
||||
SENSOR_TYPE_RAINTOTAL: ["Rain total", "mm", "mdi:water", None],
|
||||
SENSOR_TYPE_RAINRATE: [
|
||||
"Rain rate",
|
||||
f"{LENGTH_MILLIMETERS}/{TIME_HOURS}",
|
||||
"mdi:water",
|
||||
None,
|
||||
],
|
||||
SENSOR_TYPE_RAINTOTAL: ["Rain total", LENGTH_MILLIMETERS, "mdi:water", None],
|
||||
SENSOR_TYPE_WINDDIRECTION: ["Wind direction", "", "", None],
|
||||
SENSOR_TYPE_WINDAVERAGE: ["Wind average", SPEED_METERS_PER_SECOND, "", None],
|
||||
SENSOR_TYPE_WINDGUST: ["Wind gust", SPEED_METERS_PER_SECOND, "", None],
|
||||
|
@ -9,14 +9,12 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components import rpi_gpio
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.const import CONF_NAME, LENGTH_MILLIMETERS
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
LENGTH_MILLIMETERS = "mm"
|
||||
|
||||
CONF_I2C_ADDRESS = "i2c_address"
|
||||
CONF_I2C_BUS = "i2c_bus"
|
||||
CONF_XSHUT = "xshut"
|
||||
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
||||
DEGREE,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
TEMP_CELSIUS,
|
||||
@ -97,7 +98,7 @@ SENSOR_TYPES = {
|
||||
],
|
||||
"precipitation_amount": [
|
||||
"Precipitation amount",
|
||||
"mm",
|
||||
LENGTH_MILLIMETERS,
|
||||
"precipitation_amount",
|
||||
"mdi:cup-water",
|
||||
None,
|
||||
|
@ -23,6 +23,7 @@ from homeassistant.const import (
|
||||
LENGTH_INCHES,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_MILES,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
PRESSURE_INHG,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -392,7 +393,7 @@ SENSOR_TYPES = {
|
||||
"Precipitation 1hr", "precip_1hr_in", "mdi:umbrella", LENGTH_INCHES
|
||||
),
|
||||
"precip_1hr_metric": WUCurrentConditionsSensorConfig(
|
||||
"Precipitation 1hr", "precip_1hr_metric", "mdi:umbrella", "mm"
|
||||
"Precipitation 1hr", "precip_1hr_metric", "mdi:umbrella", LENGTH_MILLIMETERS
|
||||
),
|
||||
"precip_1hr_string": WUCurrentConditionsSensorConfig(
|
||||
"Precipitation 1hr", "precip_1hr_string", "mdi:umbrella"
|
||||
@ -401,7 +402,7 @@ SENSOR_TYPES = {
|
||||
"Precipitation Today", "precip_today_in", "mdi:umbrella", LENGTH_INCHES
|
||||
),
|
||||
"precip_today_metric": WUCurrentConditionsSensorConfig(
|
||||
"Precipitation Today", "precip_today_metric", "mdi:umbrella", "mm"
|
||||
"Precipitation Today", "precip_today_metric", "mdi:umbrella", LENGTH_MILLIMETERS
|
||||
),
|
||||
"precip_today_string": WUCurrentConditionsSensorConfig(
|
||||
"Precipitation Today", "precip_today_string", "mdi:umbrella"
|
||||
@ -879,16 +880,36 @@ SENSOR_TYPES = {
|
||||
"mdi:weather-windy",
|
||||
),
|
||||
"precip_1d_mm": WUDailySimpleForecastSensorConfig(
|
||||
"Precipitation Intensity Today", 0, "qpf_allday", "mm", "mm", "mdi:umbrella"
|
||||
"Precipitation Intensity Today",
|
||||
0,
|
||||
"qpf_allday",
|
||||
LENGTH_MILLIMETERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
"mdi:umbrella",
|
||||
),
|
||||
"precip_2d_mm": WUDailySimpleForecastSensorConfig(
|
||||
"Precipitation Intensity Tomorrow", 1, "qpf_allday", "mm", "mm", "mdi:umbrella"
|
||||
"Precipitation Intensity Tomorrow",
|
||||
1,
|
||||
"qpf_allday",
|
||||
LENGTH_MILLIMETERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
"mdi:umbrella",
|
||||
),
|
||||
"precip_3d_mm": WUDailySimpleForecastSensorConfig(
|
||||
"Precipitation Intensity in 3 Days", 2, "qpf_allday", "mm", "mm", "mdi:umbrella"
|
||||
"Precipitation Intensity in 3 Days",
|
||||
2,
|
||||
"qpf_allday",
|
||||
LENGTH_MILLIMETERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
"mdi:umbrella",
|
||||
),
|
||||
"precip_4d_mm": WUDailySimpleForecastSensorConfig(
|
||||
"Precipitation Intensity in 4 Days", 3, "qpf_allday", "mm", "mm", "mdi:umbrella"
|
||||
"Precipitation Intensity in 4 Days",
|
||||
3,
|
||||
"qpf_allday",
|
||||
LENGTH_MILLIMETERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
"mdi:umbrella",
|
||||
),
|
||||
"precip_1d_in": WUDailySimpleForecastSensorConfig(
|
||||
"Precipitation Intensity Today",
|
||||
|
@ -403,6 +403,7 @@ TIME_MONTHS = "m"
|
||||
TIME_YEARS = "y"
|
||||
|
||||
# Length units
|
||||
LENGTH_MILLIMETERS: str = "mm"
|
||||
LENGTH_CENTIMETERS: str = "cm"
|
||||
LENGTH_METERS: str = "m"
|
||||
LENGTH_KILOMETERS: str = "km"
|
||||
|
@ -6,7 +6,6 @@ from homeassistant.components.accuweather.const import (
|
||||
ATTRIBUTION,
|
||||
CONCENTRATION_PARTS_PER_CUBIC_METER,
|
||||
DOMAIN,
|
||||
LENGTH_MILIMETERS,
|
||||
)
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import (
|
||||
@ -17,6 +16,7 @@ from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
LENGTH_METERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
STATE_UNAVAILABLE,
|
||||
@ -52,7 +52,7 @@ async def test_sensor_without_forecast(hass):
|
||||
assert state
|
||||
assert state.state == "0.0"
|
||||
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == LENGTH_MILIMETERS
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == LENGTH_MILLIMETERS
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:weather-rainy"
|
||||
assert state.attributes.get("type") is None
|
||||
|
||||
|
@ -24,6 +24,7 @@ from homeassistant.components.homematicip_cloud.sensor import (
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -337,7 +338,7 @@ async def test_hmip_today_rain_sensor(hass, default_mock_hap_factory):
|
||||
)
|
||||
|
||||
assert ha_state.state == "3.9"
|
||||
assert ha_state.attributes[ATTR_UNIT_OF_MEASUREMENT] == "mm"
|
||||
assert ha_state.attributes[ATTR_UNIT_OF_MEASUREMENT] == LENGTH_MILLIMETERS
|
||||
await async_manipulate_test_data(hass, hmip_device, "todayRainCounter", 14.2)
|
||||
ha_state = hass.states.get(entity_id)
|
||||
assert ha_state.state == "14.2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user