init home-assistant

This commit is contained in:
2026-11-19 15:15:32 -05:00
parent 2e81d9d300
commit feec6ef9fb
19230 changed files with 3335526 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
"""The tests for the temper (USB temperature sensor) component."""
from datetime import timedelta
from unittest.mock import Mock, patch
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util
from tests.common import async_fire_time_changed
async def test_temperature_readback(hass: HomeAssistant) -> None:
"""Test for reading sensors."""
mock_temper_device = Mock()
mock_temper_device.get_temperature.return_value = 12.3
utcnow = dt_util.utcnow()
with patch(
"temperusb.temper.TemperHandler.get_devices",
return_value=[mock_temper_device],
):
await async_setup_component(
hass,
"sensor",
{"sensor": {"platform": "temper", "name": "mydevicename"}},
)
await hass.async_block_till_done()
async_fire_time_changed(hass, utcnow + timedelta(seconds=70))
await hass.async_block_till_done(wait_background_tasks=True)
temperature = hass.states.get("sensor.mydevicename")
assert temperature
assert temperature.state == "12.3"