Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/accuweather/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
LENGTH_FEET,
LENGTH_INCHES,
LENGTH_METERS,
LENGTH_MILLIMETERS,
PERCENTAGE,
SPEED_KILOMETERS_PER_HOUR,
SPEED_MILES_PER_HOUR,
Expand All @@ -24,7 +25,6 @@
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"
Expand Down Expand Up @@ -238,7 +238,7 @@
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": {
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/bom/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
CONF_NAME,
LENGTH_KILOMETERS,
LENGTH_METERS,
LENGTH_MILLIMETERS,
PERCENTAGE,
SPEED_KILOMETERS_PER_HOUR,
TEMP_CELSIUS,
Expand Down Expand Up @@ -70,7 +71,7 @@
"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],
Expand Down
45 changes: 25 additions & 20 deletions homeassistant/components/buienradar/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
DEGREE,
IRRADIATION_WATTS_PER_SQUARE_METER,
LENGTH_KILOMETERS,
LENGTH_MILLIMETERS,
PERCENTAGE,
SPEED_KILOMETERS_PER_HOUR,
TEMP_CELSIUS,
Expand Down Expand Up @@ -81,22 +82,26 @@
"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"],
Expand All @@ -107,23 +112,23 @@
"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"],
Expand Down
17 changes: 9 additions & 8 deletions homeassistant/components/darksky/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
DEGREE,
LENGTH_CENTIMETERS,
LENGTH_KILOMETERS,
LENGTH_MILLIMETERS,
PERCENTAGE,
SPEED_KILOMETERS_PER_HOUR,
SPEED_METERS_PER_SECOND,
Expand Down Expand Up @@ -109,11 +110,11 @@
],
"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"],
],
Expand Down Expand Up @@ -329,11 +330,11 @@
],
"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"],
],
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/homematic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DEVICE_CLASS_TEMPERATURE,
ENERGY_WATT_HOUR,
FREQUENCY_HERTZ,
LENGTH_MILLIMETERS,
PERCENTAGE,
POWER_WATT,
SPEED_KILOMETERS_PER_HOUR,
Expand Down Expand Up @@ -54,7 +55,7 @@
"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,
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/homematicip_cloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE,
LENGTH_MILLIMETERS,
PERCENTAGE,
POWER_WATT,
SPEED_KILOMETERS_PER_HOUR,
Expand Down Expand Up @@ -367,7 +368,7 @@ def state(self) -> float:
@property
def unit_of_measurement(self) -> str:
"""Return the unit this state is expressed in."""
return "mm"
return LENGTH_MILLIMETERS


class HomematicipPassageDetectorDeltaCounter(HomematicipGenericEntity):
Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/isy994/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
LENGTH_KILOMETERS,
LENGTH_METERS,
LENGTH_MILES,
LENGTH_MILLIMETERS,
MASS_KILOGRAMS,
MASS_POUNDS,
PERCENTAGE,
Expand Down Expand Up @@ -356,7 +357,7 @@
"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,
Expand All @@ -383,7 +384,7 @@
"75": "weekday",
"76": DEGREE,
"77": TIME_YEARS,
"82": "mm",
"82": LENGTH_MILLIMETERS,
"83": LENGTH_KILOMETERS,
"85": "Ω",
"86": "kΩ",
Expand All @@ -399,7 +400,7 @@
"103": "$",
"104": "¢",
"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
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/meteo_france/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
LENGTH_MILLIMETERS,
PERCENTAGE,
PRESSURE_HPA,
SPEED_KILOMETERS_PER_HOUR,
Expand Down Expand Up @@ -108,7 +109,7 @@
},
"precipitation": {
ENTITY_NAME: "Daily precipitation",
ENTITY_UNIT: "mm",
ENTITY_UNIT: LENGTH_MILLIMETERS,
ENTITY_ICON: "mdi:cup-water",
ENTITY_DEVICE_CLASS: None,
ENTITY_ENABLE: True,
Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/netatmo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_SIGNAL_STRENGTH,
DEVICE_CLASS_TEMPERATURE,
LENGTH_MILLIMETERS,
PERCENTAGE,
PRESSURE_MBAR,
SPEED_KILOMETERS_PER_HOUR,
Expand Down Expand Up @@ -52,9 +53,9 @@
"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],
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/openweathermap/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
LENGTH_MILLIMETERS,
PERCENTAGE,
PRESSURE_PA,
SPEED_METERS_PER_SECOND,
Expand Down Expand Up @@ -112,8 +113,8 @@
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"},
}
Expand Down
10 changes: 8 additions & 2 deletions homeassistant/components/tellduslive/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_TEMPERATURE,
LENGTH_MILLIMETERS,
PERCENTAGE,
POWER_WATT,
SPEED_METERS_PER_SECOND,
Expand Down Expand Up @@ -40,8 +41,13 @@
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],
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/components/tof/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@

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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DEGREE,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
LENGTH_MILLIMETERS,
PERCENTAGE,
SPEED_METERS_PER_SECOND,
TEMP_CELSIUS,
Expand Down Expand Up @@ -97,7 +98,7 @@
],
"precipitation_amount": [
"Precipitation amount",
"mm",
LENGTH_MILLIMETERS,
"precipitation_amount",
"mdi:cup-water",
None,
Expand Down
Loading