mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-11-05 07:02:05 +00:00
Add ADC Value to PIR Enabled Switches
- Add: ADC value reporting to PIR enabled switches, so that it may be used in polling automations. - Add: ADC trigger state value reporting, for simpler automations. - Add: Ability for features to use custom value parsers.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from kasa import Module
|
||||
from kasa.exceptions import KasaException
|
||||
from kasa.iot import IotDimmer
|
||||
from kasa.iot.modules.motion import Motion, Range
|
||||
|
||||
@@ -36,7 +38,14 @@ async def test_motion_range(dev: IotDimmer, mocker: MockerFixture):
|
||||
motion: Motion = dev.modules[Module.IotMotion]
|
||||
query_helper = mocker.patch("kasa.iot.IotDimmer._query_helper")
|
||||
|
||||
await motion.set_range(custom_range=123)
|
||||
await motion.set_range(value=123)
|
||||
query_helper.assert_called_with(
|
||||
"smartlife.iot.PIR",
|
||||
"set_trigger_sens",
|
||||
{"index": Range.Custom.value, "value": 123},
|
||||
)
|
||||
|
||||
await motion.set_range(range=Range.Custom, value=123)
|
||||
query_helper.assert_called_with(
|
||||
"smartlife.iot.PIR",
|
||||
"set_trigger_sens",
|
||||
@@ -48,6 +57,14 @@ async def test_motion_range(dev: IotDimmer, mocker: MockerFixture):
|
||||
"smartlife.iot.PIR", "set_trigger_sens", {"index": Range.Far.value}
|
||||
)
|
||||
|
||||
with pytest.raises(KasaException, match="Refusing to set non-custom range"):
|
||||
await motion.set_range(range=Range.Near, value=100) # type: ignore[call-overload]
|
||||
|
||||
with pytest.raises(
|
||||
KasaException, match="Either range or value needs to be defined"
|
||||
):
|
||||
await motion.set_range() # type: ignore[call-overload]
|
||||
|
||||
|
||||
@dimmer_iot
|
||||
def test_motion_feature(dev: IotDimmer):
|
||||
|
||||
Reference in New Issue
Block a user