Darksky enhancements (#9851)
* Correct capitalization inconsistency in DarkSky All two-word sensors ("Precip Intensity," "Nearest Storm Bearing," etc) in Darksky uses title case for the friendly name of the sensor, with the exception of "Dew point." * Implement UV Index in Darksky * Fixed whitespace for Tox compliance * Add unit for UV Index. Per recommendation of reviewer, added 'UV Index' as a CONST in const.py, then used that const in both DarkSky and ISY994. It looks like BloomSky might also support UV Index and it should probably be standardized.
This commit is contained in:
parent
fd6c2598a7
commit
f807a3a890
3 changed files with 12 additions and 5 deletions
|
@ -14,7 +14,7 @@ from requests.exceptions import ConnectionError as ConnectError, \
|
|||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY, CONF_NAME, CONF_MONITORED_CONDITIONS, ATTR_ATTRIBUTION,
|
||||
CONF_LATITUDE, CONF_LONGITUDE)
|
||||
CONF_LATITUDE, CONF_LONGITUDE, UNIT_UV_INDEX)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -62,7 +62,7 @@ SENSOR_TYPES = {
|
|||
'apparent_temperature': ['Apparent Temperature',
|
||||
'°C', '°F', '°C', '°C', '°C', 'mdi:thermometer',
|
||||
['currently', 'hourly']],
|
||||
'dew_point': ['Dew point', '°C', '°F', '°C', '°C', '°C',
|
||||
'dew_point': ['Dew Point', '°C', '°F', '°C', '°C', '°C',
|
||||
'mdi:thermometer', ['currently', 'hourly', 'daily']],
|
||||
'wind_speed': ['Wind Speed', 'm/s', 'mph', 'km/h', 'mph', 'mph',
|
||||
'mdi:weather-windy', ['currently', 'hourly', 'daily']],
|
||||
|
@ -96,6 +96,10 @@ SENSOR_TYPES = {
|
|||
'precip_intensity_max': ['Daily Max Precip Intensity',
|
||||
'mm', 'in', 'mm', 'mm', 'mm', 'mdi:thermometer',
|
||||
['currently', 'hourly', 'daily']],
|
||||
'uv_index': ['UV Index',
|
||||
UNIT_UV_INDEX, UNIT_UV_INDEX, UNIT_UV_INDEX,
|
||||
UNIT_UV_INDEX, UNIT_UV_INDEX, 'mdi:weather-sunny',
|
||||
['currently', 'hourly', 'daily']],
|
||||
}
|
||||
|
||||
CONDITION_PICTURES = {
|
||||
|
@ -305,7 +309,7 @@ class DarkSkySensor(Entity):
|
|||
'temperature_min', 'temperature_max',
|
||||
'apparent_temperature_min',
|
||||
'apparent_temperature_max',
|
||||
'pressure', 'ozone']):
|
||||
'pressure', 'ozone', 'uvIndex']):
|
||||
return round(state, 1)
|
||||
return state
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from typing import Callable # noqa
|
|||
|
||||
import homeassistant.components.isy994 as isy
|
||||
from homeassistant.const import (
|
||||
TEMP_CELSIUS, TEMP_FAHRENHEIT, STATE_OFF, STATE_ON)
|
||||
TEMP_CELSIUS, TEMP_FAHRENHEIT, STATE_OFF, STATE_ON, UNIT_UV_INDEX)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -77,7 +77,7 @@ UOM_FRIENDLY_NAME = {
|
|||
'64': 'shindo',
|
||||
'65': 'SML',
|
||||
'69': 'gal',
|
||||
'71': 'UV index',
|
||||
'71': UNIT_UV_INDEX,
|
||||
'72': 'V',
|
||||
'73': 'W',
|
||||
'74': 'W/m²',
|
||||
|
|
|
@ -279,6 +279,9 @@ MASS_KILOGRAMS = 'kg' # type: str
|
|||
MASS_OUNCES = 'oz' # type: str
|
||||
MASS_POUNDS = 'lb' # type: str
|
||||
|
||||
# UV Index units
|
||||
UNIT_UV_INDEX = 'UV index' # type: str
|
||||
|
||||
# Contains the information that is discovered
|
||||
ATTR_DISCOVERED = 'discovered'
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue