From 142b114344bda62f440e127e122ca28300f2acfe Mon Sep 17 00:00:00 2001 From: springstan Date: Tue, 15 Sep 2020 17:02:57 +0000 Subject: [PATCH] Use AREA_SQUARE_METERS constant in all integrations --- homeassistant/components/ambient_station/__init__.py | 8 +++++++- homeassistant/components/bloomsky/sensor.py | 5 +++-- homeassistant/components/isy994/const.py | 3 ++- homeassistant/components/smartthings/sensor.py | 8 +++++++- homeassistant/components/zamg/sensor.py | 8 +++++++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/ambient_station/__init__.py b/homeassistant/components/ambient_station/__init__.py index f8b2cd7348db4c..ac8ae18a65754e 100644 --- a/homeassistant/components/ambient_station/__init__.py +++ b/homeassistant/components/ambient_station/__init__.py @@ -9,6 +9,7 @@ from homeassistant.components.binary_sensor import DEVICE_CLASS_CONNECTIVITY from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.const import ( + AREA_SQUARE_METERS, ATTR_LOCATION, ATTR_NAME, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, @@ -206,7 +207,12 @@ TYPE_SOILTEMP7F: ("Soil Temp 7", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP8F: ("Soil Temp 8", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP9F: ("Soil Temp 9", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), - TYPE_SOLARRADIATION: ("Solar Rad", f"{POWER_WATT}/m^2", TYPE_SENSOR, None), + TYPE_SOLARRADIATION: ( + "Solar Rad", + f"{POWER_WATT}/{AREA_SQUARE_METERS}", + TYPE_SENSOR, + None, + ), TYPE_SOLARRADIATION_LX: ("Solar Rad (lx)", "lx", TYPE_SENSOR, "illuminance"), TYPE_TEMP10F: ("Temp 10", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP1F: ("Temp 1", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), diff --git a/homeassistant/components/bloomsky/sensor.py b/homeassistant/components/bloomsky/sensor.py index 0ddeec6a5773a3..812efe7697e4be 100644 --- a/homeassistant/components/bloomsky/sensor.py +++ b/homeassistant/components/bloomsky/sensor.py @@ -5,6 +5,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( + AREA_SQUARE_METERS, CONF_MONITORED_CONDITIONS, PERCENTAGE, TEMP_CELSIUS, @@ -32,7 +33,7 @@ "Temperature": TEMP_FAHRENHEIT, "Humidity": PERCENTAGE, "Pressure": "inHg", - "Luminance": "cd/m²", + "Luminance": f"cd/{AREA_SQUARE_METERS}", "Voltage": "mV", } @@ -41,7 +42,7 @@ "Temperature": TEMP_CELSIUS, "Humidity": PERCENTAGE, "Pressure": "mbar", - "Luminance": "cd/m²", + "Luminance": f"cd/{AREA_SQUARE_METERS}", "Voltage": "mV", } diff --git a/homeassistant/components/isy994/const.py b/homeassistant/components/isy994/const.py index d911fae2c82fc7..2bf3ab91c0716c 100644 --- a/homeassistant/components/isy994/const.py +++ b/homeassistant/components/isy994/const.py @@ -44,6 +44,7 @@ from homeassistant.components.sensor import DOMAIN as SENSOR from homeassistant.components.switch import DOMAIN as SWITCH from homeassistant.const import ( + AREA_SQUARE_METERS, CONCENTRATION_PARTS_PER_MILLION, DEGREE, ENERGY_KILO_WATT_HOUR, @@ -377,7 +378,7 @@ "71": UV_INDEX, "72": VOLT, "73": POWER_WATT, - "74": f"{POWER_WATT}/{LENGTH_METERS}²", + "74": f"{POWER_WATT}/{AREA_SQUARE_METERS}", "75": "weekday", "76": DEGREE, "77": TIME_YEARS, diff --git a/homeassistant/components/smartthings/sensor.py b/homeassistant/components/smartthings/sensor.py index 7de3b98b1da497..a7a15e3cefcfed 100644 --- a/homeassistant/components/smartthings/sensor.py +++ b/homeassistant/components/smartthings/sensor.py @@ -5,6 +5,7 @@ from pysmartthings import Attribute, Capability from homeassistant.const import ( + AREA_SQUARE_METERS, CONCENTRATION_PARTS_PER_MILLION, DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, @@ -41,7 +42,12 @@ Map(Attribute.battery, "Battery", PERCENTAGE, DEVICE_CLASS_BATTERY) ], Capability.body_mass_index_measurement: [ - Map(Attribute.bmi_measurement, "Body Mass Index", f"{MASS_KILOGRAMS}/m^2", None) + Map( + Attribute.bmi_measurement, + "Body Mass Index", + f"{MASS_KILOGRAMS}/{AREA_SQUARE_METERS}", + None, + ) ], Capability.body_weight_measurement: [ Map(Attribute.body_weight_measurement, "Body Weight", MASS_KILOGRAMS, None) diff --git a/homeassistant/components/zamg/sensor.py b/homeassistant/components/zamg/sensor.py index 0aa5dea0687c38..9372be58493516 100644 --- a/homeassistant/components/zamg/sensor.py +++ b/homeassistant/components/zamg/sensor.py @@ -12,6 +12,7 @@ import voluptuous as vol from homeassistant.const import ( + AREA_SQUARE_METERS, ATTR_ATTRIBUTION, CONF_LATITUDE, CONF_LONGITUDE, @@ -60,7 +61,12 @@ "wind_max_bearing": ("Top Wind Bearing", DEGREE, f"WSR {DEGREE}", int), "sun_last_hour": ("Sun Last Hour", PERCENTAGE, f"SO {PERCENTAGE}", int), "temperature": ("Temperature", TEMP_CELSIUS, f"T {TEMP_CELSIUS}", float), - "precipitation": ("Precipitation", "l/m²", "N l/m²", float), + "precipitation": ( + "Precipitation", + f"l/{AREA_SQUARE_METERS}", + f"N l/{AREA_SQUARE_METERS}", + float, + ), "dewpoint": ("Dew Point", TEMP_CELSIUS, f"TP {TEMP_CELSIUS}", float), # The following probably not useful for general consumption, # but we need them to fill in internal attributes