mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Use LENGTH_METERS constant (#34110)
This commit is contained in:
parent
538bb60022
commit
00b6409b76
@ -20,6 +20,7 @@ from homeassistant.const import (
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_METERS,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_PERCENTAGE,
|
||||
@ -73,7 +74,7 @@ SENSOR_TYPES = {
|
||||
"rel_hum": ["Relative Humidity", UNIT_PERCENTAGE],
|
||||
"sea_state": ["Sea State", None],
|
||||
"swell_dir_worded": ["Swell Direction", None],
|
||||
"swell_height": ["Swell Height", "m"],
|
||||
"swell_height": ["Swell Height", LENGTH_METERS],
|
||||
"swell_period": ["Swell Period", None],
|
||||
"vis_km": [f"Visability {LENGTH_KILOMETERS}", LENGTH_KILOMETERS],
|
||||
"weather": ["Weather", None],
|
||||
|
@ -15,6 +15,7 @@ from homeassistant.const import (
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
CONF_SCAN_INTERVAL,
|
||||
LENGTH_CENTIMETERS,
|
||||
LENGTH_KILOMETERS,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
@ -128,11 +129,11 @@ SENSOR_TYPES = {
|
||||
],
|
||||
"precip_accumulation": [
|
||||
"Precip Accumulation",
|
||||
"cm",
|
||||
LENGTH_CENTIMETERS,
|
||||
"in",
|
||||
"cm",
|
||||
"cm",
|
||||
"cm",
|
||||
LENGTH_CENTIMETERS,
|
||||
LENGTH_CENTIMETERS,
|
||||
LENGTH_CENTIMETERS,
|
||||
"mdi:weather-snowy",
|
||||
["hourly", "daily"],
|
||||
],
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Constants for the Garmin Connect integration."""
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_TIMESTAMP,
|
||||
LENGTH_METERS,
|
||||
MASS_KILOGRAMS,
|
||||
TIME_MINUTES,
|
||||
UNIT_PERCENTAGE,
|
||||
@ -32,7 +33,13 @@ GARMIN_ENTITY_LIST = {
|
||||
False,
|
||||
],
|
||||
"netCalorieGoal": ["Net Calorie Goal", "cal", "mdi:food", None, False],
|
||||
"totalDistanceMeters": ["Total Distance Mtr", "m", "mdi:walk", None, True],
|
||||
"totalDistanceMeters": [
|
||||
"Total Distance Mtr",
|
||||
LENGTH_METERS,
|
||||
"mdi:walk",
|
||||
None,
|
||||
True,
|
||||
],
|
||||
"wellnessStartTimeLocal": [
|
||||
"Wellness Start Time",
|
||||
"",
|
||||
@ -48,7 +55,13 @@ GARMIN_ENTITY_LIST = {
|
||||
False,
|
||||
],
|
||||
"wellnessDescription": ["Wellness Description", "", "mdi:clock", None, False],
|
||||
"wellnessDistanceMeters": ["Wellness Distance Mtr", "m", "mdi:walk", None, False],
|
||||
"wellnessDistanceMeters": [
|
||||
"Wellness Distance Mtr",
|
||||
LENGTH_METERS,
|
||||
"mdi:walk",
|
||||
None,
|
||||
False,
|
||||
],
|
||||
"wellnessActiveKilocalories": [
|
||||
"Wellness Active KiloCalories",
|
||||
"kcal",
|
||||
@ -81,8 +94,20 @@ GARMIN_ENTITY_LIST = {
|
||||
None,
|
||||
True,
|
||||
],
|
||||
"floorsAscendedInMeters": ["Floors Ascended Mtr", "m", "mdi:stairs", None, False],
|
||||
"floorsDescendedInMeters": ["Floors Descended Mtr", "m", "mdi:stairs", None, False],
|
||||
"floorsAscendedInMeters": [
|
||||
"Floors Ascended Mtr",
|
||||
LENGTH_METERS,
|
||||
"mdi:stairs",
|
||||
None,
|
||||
False,
|
||||
],
|
||||
"floorsDescendedInMeters": [
|
||||
"Floors Descended Mtr",
|
||||
LENGTH_METERS,
|
||||
"mdi:stairs",
|
||||
None,
|
||||
False,
|
||||
],
|
||||
"floorsAscended": ["Floors Ascended", "floors", "mdi:stairs", None, True],
|
||||
"floorsDescended": ["Floors Descended", "floors", "mdi:stairs", None, True],
|
||||
"userFloorsAscendedGoal": [
|
||||
|
@ -5,7 +5,9 @@ from typing import Callable
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
LENGTH_CENTIMETERS,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_METERS,
|
||||
MASS_KILOGRAMS,
|
||||
POWER_WATT,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
@ -35,7 +37,7 @@ UOM_FRIENDLY_NAME = {
|
||||
"1": "amp",
|
||||
"3": f"btu/{TIME_HOURS}",
|
||||
"4": TEMP_CELSIUS,
|
||||
"5": "cm",
|
||||
"5": LENGTH_CENTIMETERS,
|
||||
"6": "ft³",
|
||||
"7": f"ft³/{TIME_MINUTES}",
|
||||
"8": "m³",
|
||||
@ -66,7 +68,7 @@ UOM_FRIENDLY_NAME = {
|
||||
"35": "l",
|
||||
"36": "lx",
|
||||
"37": "mercalli",
|
||||
"38": "m",
|
||||
"38": LENGTH_METERS,
|
||||
"39": "m³/hr",
|
||||
"40": SPEED_METERS_PER_SECOND,
|
||||
"41": "mA",
|
||||
|
@ -3,6 +3,7 @@ from homeassistant.components import mysensors
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
LENGTH_METERS,
|
||||
MASS_KILOGRAMS,
|
||||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
@ -26,12 +27,12 @@ SENSORS = {
|
||||
"V_GUST": [None, "mdi:weather-windy"],
|
||||
"V_DIRECTION": [UNIT_DEGREE, "mdi:compass"],
|
||||
"V_WEIGHT": [MASS_KILOGRAMS, "mdi:weight-kilogram"],
|
||||
"V_DISTANCE": ["m", "mdi:ruler"],
|
||||
"V_DISTANCE": [LENGTH_METERS, "mdi:ruler"],
|
||||
"V_IMPEDANCE": ["ohm", None],
|
||||
"V_WATT": [POWER_WATT, None],
|
||||
"V_KWH": [ENERGY_KILO_WATT_HOUR, None],
|
||||
"V_LIGHT_LEVEL": [UNIT_PERCENTAGE, "mdi:white-balance-sunny"],
|
||||
"V_FLOW": ["m", "mdi:gauge"],
|
||||
"V_FLOW": [LENGTH_METERS, "mdi:gauge"],
|
||||
"V_VOLUME": ["m³", None],
|
||||
"V_LEVEL": {
|
||||
"S_SOUND": ["dB", "mdi:volume-high"],
|
||||
|
@ -8,6 +8,7 @@ from homeassistant.const import (
|
||||
CONF_UNIT_OF_MEASUREMENT,
|
||||
CONF_ZONE,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_METERS,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
@ -33,7 +34,7 @@ DEFAULT_PROXIMITY_ZONE = "home"
|
||||
DEFAULT_TOLERANCE = 1
|
||||
DOMAIN = "proximity"
|
||||
|
||||
UNITS = [LENGTH_KILOMETERS, "m", "mi", "ft"]
|
||||
UNITS = [LENGTH_KILOMETERS, LENGTH_METERS, "mi", "ft"]
|
||||
|
||||
ZONE_SCHEMA = vol.Schema(
|
||||
{
|
||||
@ -210,7 +211,7 @@ class Proximity(Entity):
|
||||
|
||||
# Add the device and distance to a dictionary.
|
||||
distances_to_zone[device] = round(
|
||||
convert(dist_to_zone, "m", self.unit_of_measurement), 1
|
||||
convert(dist_to_zone, LENGTH_METERS, self.unit_of_measurement), 1
|
||||
)
|
||||
|
||||
# Loop through each of the distances collected and work out the
|
||||
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
||||
CONF_LONGITUDE,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
LENGTH_METERS,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_DEGREE,
|
||||
@ -64,7 +65,12 @@ SENSOR_TYPES = {
|
||||
# The following probably not useful for general consumption,
|
||||
# but we need them to fill in internal attributes
|
||||
"station_name": ("Station Name", None, "Name", str),
|
||||
"station_elevation": ("Station Elevation", "m", "Höhe m", int),
|
||||
"station_elevation": (
|
||||
"Station Elevation",
|
||||
LENGTH_METERS,
|
||||
f"Höhe {LENGTH_METERS}",
|
||||
int,
|
||||
),
|
||||
"update_date": ("Update Date", None, "Datum", str),
|
||||
"update_time": ("Update Time", None, "Zeit", str),
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ from homeassistant.const import (
|
||||
EVENT_STATE_CHANGED,
|
||||
EVENT_TIME_CHANGED,
|
||||
EVENT_TIMER_OUT_OF_SYNC,
|
||||
LENGTH_METERS,
|
||||
MATCH_ALL,
|
||||
__version__,
|
||||
)
|
||||
@ -1324,7 +1325,7 @@ class Config:
|
||||
Async friendly.
|
||||
"""
|
||||
return self.units.length(
|
||||
location.distance(self.latitude, self.longitude, lat, lon), "m"
|
||||
location.distance(self.latitude, self.longitude, lat, lon), LENGTH_METERS
|
||||
)
|
||||
|
||||
def path(self, *path: str) -> str:
|
||||
|
@ -19,6 +19,7 @@ from homeassistant.const import (
|
||||
ATTR_LATITUDE,
|
||||
ATTR_LONGITUDE,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
LENGTH_METERS,
|
||||
MATCH_ALL,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
@ -638,7 +639,7 @@ def distance(hass, *args):
|
||||
return hass.config.distance(*locations[0])
|
||||
|
||||
return hass.config.units.length(
|
||||
loc_util.distance(*locations[0] + locations[1]), "m"
|
||||
loc_util.distance(*locations[0] + locations[1]), LENGTH_METERS
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user