2024-04-22 11:39:07 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from kasa.smart.modules import TemperatureSensor
|
2024-04-22 14:24:15 +00:00
|
|
|
from kasa.tests.device_fixtures import parametrize, thermostats_smart
|
2024-04-22 11:39:07 +00:00
|
|
|
|
|
|
|
temperature = parametrize(
|
|
|
|
"has temperature control",
|
|
|
|
component_filter="temperature_control",
|
|
|
|
protocol_filter={"SMART.CHILD"},
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-04-22 14:24:15 +00:00
|
|
|
@thermostats_smart
|
2024-04-22 11:39:07 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"feature, type",
|
|
|
|
[
|
2024-04-22 14:24:15 +00:00
|
|
|
("target_temperature", float),
|
2024-04-22 11:39:07 +00:00
|
|
|
("temperature_offset", int),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
async def test_temperature_control_features(dev, feature, type):
|
|
|
|
"""Test that features are registered and work as expected."""
|
|
|
|
temp_module: TemperatureSensor = dev.modules["TemperatureControl"]
|
|
|
|
|
|
|
|
prop = getattr(temp_module, feature)
|
|
|
|
assert isinstance(prop, type)
|
|
|
|
|
|
|
|
feat = temp_module._module_features[feature]
|
|
|
|
assert feat.value == prop
|
|
|
|
assert isinstance(feat.value, type)
|
|
|
|
|
|
|
|
await feat.set_value(10)
|
|
|
|
await dev.update()
|
|
|
|
assert feat.value == 10
|