Add weatherkit sensor platform (#101150)

* Add weatherkit sensor platform and tests

* Make unique ID assignment more explicit

* Fix missing argument

* Use const for top-level API response keys

* Address code review feedback
This commit is contained in:
TJ Horner
2023-10-01 23:20:09 +02:00
committed by GitHub
parent 9261ad14e2
commit cabfbc245d
8 changed files with 167 additions and 21 deletions
@@ -19,7 +19,7 @@
"conditionCode": "PartlyCloudy",
"daylight": true,
"humidity": 0.91,
"precipitationIntensity": 0.0,
"precipitationIntensity": 0.7,
"pressure": 1009.8,
"pressureTrend": "rising",
"temperature": 22.9,
@@ -0,0 +1,27 @@
"""Sensor entity tests for the WeatherKit integration."""
from typing import Any
import pytest
from homeassistant.core import HomeAssistant
from . import init_integration
@pytest.mark.parametrize(
("entity_name", "expected_value"),
[
("sensor.home_precipitation_intensity", 0.7),
("sensor.home_pressure_trend", "rising"),
],
)
async def test_sensor_values(
hass: HomeAssistant, entity_name: str, expected_value: Any
) -> None:
"""Test that various sensor values match what we expect."""
await init_integration(hass)
state = hass.states.get(entity_name)
assert state
assert state.state == str(expected_value)