Add and use more unit constants (#32122)

* Add and use speed constants

* Add and use meter based volume and area constants

* Add and use more mass unit constants

* Add and use concentration unit constants

* Add and use watts per square meter constant

* Use more time constants

* Use more data constants
This commit is contained in:
Ville Skyttä authored and GitHub committed 2020-02-24 17:52:14 -08:00
1 parent c98f50115d
commit 496bd3dddf
44 files changed
+422 -177

No files matched your search

+15 -4
View File
@@ -5,11 +5,12 @@ import logging
import pyatmo
from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
SPEED_KILOMETERS_PER_HOUR,
TEMP_CELSIUS,
TIME_HOURS,
)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
@@ -53,7 +54,7 @@ SENSOR_TYPES = {
"mdi:thermometer",
DEVICE_CLASS_TEMPERATURE,
],
"co2": ["CO2", "ppm", "mdi:periodic-table-co2", None],
"co2": ["CO2", CONCENTRATION_PARTS_PER_MILLION, "mdi:periodic-table-co2", None],
"pressure": ["Pressure", "mbar", "mdi:gauge", None],
"noise": ["Noise", "dB", "mdi:volume-high", None],
"humidity": ["Humidity", "%", "mdi:water-percent", DEVICE_CLASS_HUMIDITY],
@@ -67,10 +68,20 @@ SENSOR_TYPES = {
"max_temp": ["Max Temp.", TEMP_CELSIUS, "mdi:thermometer", None],
"windangle": ["Angle", "", "mdi:compass", None],
"windangle_value": ["Angle Value", "º", "mdi:compass", None],
"windstrength": ["Wind Strength", f"km/{TIME_HOURS}", "mdi:weather-windy", None],
"windstrength": [
"Wind Strength",
SPEED_KILOMETERS_PER_HOUR,
"mdi:weather-windy",
None,
],
"gustangle": ["Gust Angle", "", "mdi:compass", None],
"gustangle_value": ["Gust Angle Value", "º", "mdi:compass", None],
"guststrength": ["Gust Strength", f"km/{TIME_HOURS}", "mdi:weather-windy", None],
"guststrength": [
"Gust Strength",
SPEED_KILOMETERS_PER_HOUR,
"mdi:weather-windy",
None,
],
"reachable": ["Reachability", "", "mdi:signal", None],
"rf_status": ["Radio", "", "mdi:signal", None],
"rf_status_lvl": ["Radio_lvl", "", "mdi:signal", None],