Add and use UNIT_DEGREE constant (#33978)

* Add and use UNIT_DEGREE constant

* Replace more occurrences

* Add and use TEMP_KELVIN

* Run isort
This commit is contained in:
springstan authored and GitHub committed 2020-04-11 16:54:11 +02:00
1 parent c18a6d5ea3
commit b893150154
19 files changed
+67 -47

No files matched your search

+2 -1
View File
@@ -9,6 +9,7 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
DEVICE_CLASS_POWER,
ENERGY_KILO_WATT_HOUR,
UNIT_DEGREE,
)
from homeassistant.setup import async_setup_component
@@ -47,7 +48,7 @@ async def prometheus_client(loop, hass, hass_client):
sensor3.entity_id = "sensor.electricity_price"
await sensor3.async_update_ha_state()
sensor4 = DemoSensor(None, "Wind Direction", 25, None, "°", None)
sensor4 = DemoSensor(None, "Wind Direction", 25, None, UNIT_DEGREE, None)
sensor4.hass = hass
sensor4.entity_id = "sensor.wind_direction"
await sensor4.async_update_ha_state()
+3 -3
View File
@@ -3,7 +3,7 @@ from datetime import datetime
from unittest.mock import patch
from homeassistant.bootstrap import async_setup_component
from homeassistant.const import SPEED_METERS_PER_SECOND, UNIT_PERCENTAGE
from homeassistant.const import SPEED_METERS_PER_SECOND, UNIT_DEGREE, UNIT_PERCENTAGE
import homeassistant.util.dt as dt_util
from tests.common import assert_setup_component, load_fixture
@@ -59,7 +59,7 @@ async def test_custom_setup(hass, aioclient_mock):
assert state.state == "1009.3"
state = hass.states.get("sensor.yr_wind_direction")
assert state.attributes.get("unit_of_measurement") == "°"
assert state.attributes.get("unit_of_measurement") == UNIT_DEGREE
assert state.state == "103.6"
state = hass.states.get("sensor.yr_humidity")
@@ -105,7 +105,7 @@ async def test_forecast_setup(hass, aioclient_mock):
assert state.state == "1008.3"
state = hass.states.get("sensor.yr_wind_direction")
assert state.attributes.get("unit_of_measurement") == "°"
assert state.attributes.get("unit_of_measurement") == UNIT_DEGREE
assert state.state == "148.9"
state = hass.states.get("sensor.yr_humidity")