1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add nws sensor platform (#45027)

* Resolve rebase conflict.

Remove logging

* lint: fix elif after return

* fix attribution

* add tests for None valuea

* Remove Entity import

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Import SensorEntity

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Inherit SensorEntity

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* remove unused logging

* Use CoordinatorEntity

* Use type instead of name.

* add all entities

* add nice rounding to temperature and humidity

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
MatthewFlamm
2021-04-01 12:50:37 -04:00
committed by GitHub
parent 9f481e1642
commit f8f0495319
8 changed files with 435 additions and 23 deletions

View File

@@ -44,6 +44,7 @@ DEFAULT_STATIONS = ["ABC", "XYZ"]
DEFAULT_OBSERVATION = {
"temperature": 10,
"seaLevelPressure": 100000,
"barometricPressure": 100000,
"relativeHumidity": 10,
"windSpeed": 10,
"windDirection": 180,
@@ -53,9 +54,45 @@ DEFAULT_OBSERVATION = {
"timestamp": "2019-08-12T23:53:00+00:00",
"iconTime": "day",
"iconWeather": (("Fair/clear", None),),
"dewpoint": 5,
"windChill": 5,
"heatIndex": 15,
"windGust": 20,
}
EXPECTED_OBSERVATION_IMPERIAL = {
SENSOR_EXPECTED_OBSERVATION_METRIC = {
"dewpoint": "5",
"temperature": "10",
"windChill": "5",
"heatIndex": "15",
"relativeHumidity": "10",
"windSpeed": "10",
"windGust": "20",
"windDirection": "180",
"barometricPressure": "100000",
"seaLevelPressure": "100000",
"visibility": "10000",
}
SENSOR_EXPECTED_OBSERVATION_IMPERIAL = {
"dewpoint": str(round(convert_temperature(5, TEMP_CELSIUS, TEMP_FAHRENHEIT))),
"temperature": str(round(convert_temperature(10, TEMP_CELSIUS, TEMP_FAHRENHEIT))),
"windChill": str(round(convert_temperature(5, TEMP_CELSIUS, TEMP_FAHRENHEIT))),
"heatIndex": str(round(convert_temperature(15, TEMP_CELSIUS, TEMP_FAHRENHEIT))),
"relativeHumidity": "10",
"windSpeed": str(round(convert_distance(10, LENGTH_KILOMETERS, LENGTH_MILES))),
"windGust": str(round(convert_distance(20, LENGTH_KILOMETERS, LENGTH_MILES))),
"windDirection": "180",
"barometricPressure": str(
round(convert_pressure(100000, PRESSURE_PA, PRESSURE_INHG), 2)
),
"seaLevelPressure": str(
round(convert_pressure(100000, PRESSURE_PA, PRESSURE_INHG), 2)
),
"visibility": str(round(convert_distance(10000, LENGTH_METERS, LENGTH_MILES))),
}
WEATHER_EXPECTED_OBSERVATION_IMPERIAL = {
ATTR_WEATHER_TEMPERATURE: round(
convert_temperature(10, TEMP_CELSIUS, TEMP_FAHRENHEIT)
),
@@ -72,7 +109,7 @@ EXPECTED_OBSERVATION_IMPERIAL = {
ATTR_WEATHER_HUMIDITY: 10,
}
EXPECTED_OBSERVATION_METRIC = {
WEATHER_EXPECTED_OBSERVATION_METRIC = {
ATTR_WEATHER_TEMPERATURE: 10,
ATTR_WEATHER_WIND_BEARING: 180,
ATTR_WEATHER_WIND_SPEED: 10,