mirror of
				https://github.com/python-kasa/python-kasa.git
				synced 2025-10-31 12:41:54 +00:00 
			
		
		
		
	Add Async ADC PIR Support
- Add: Async function to get the current state of the ADC PIR sensor. - Fix: Move ADC PIR state and config into proper dataclasses. - Add: Add CLI test for passing bad quotes to feature set.
This commit is contained in:
		| @@ -68,6 +68,15 @@ async def test_motion_threshold(dev: IotDimmer, mocker: MockerFixture): | ||||
|         ) | ||||
|  | ||||
|  | ||||
| @dimmer_iot | ||||
| async def test_motion_realtime(dev: IotDimmer, mocker: MockerFixture): | ||||
|     motion: Motion = dev.modules[Module.IotMotion] | ||||
|     query_helper = mocker.patch("kasa.iot.IotDimmer._query_helper") | ||||
|  | ||||
|     await motion.get_pir_state() | ||||
|     query_helper.assert_called_with("smartlife.iot.PIR", "get_adc_value", None) | ||||
|  | ||||
|  | ||||
| @dimmer_iot | ||||
| def test_motion_feature(dev: IotDimmer): | ||||
|     assert Module.IotMotion in dev.modules | ||||
|   | ||||
| @@ -1119,6 +1119,44 @@ async def test_feature_set_child(mocker, runner): | ||||
|     assert res.exit_code == 0 | ||||
|  | ||||
|  | ||||
| async def test_feature_set_unquoted(mocker, runner): | ||||
|     """Test feature command's set value.""" | ||||
|     dummy_device = await get_device_for_fixture_protocol( | ||||
|         "ES20M(US)_1.0_1.0.11.json", "IOT" | ||||
|     ) | ||||
|     range_setter = mocker.patch("kasa.iot.modules.motion.Motion._set_range_cli") | ||||
|     mocker.patch("kasa.discover.Discover.discover_single", return_value=dummy_device) | ||||
|  | ||||
|     res = await runner.invoke( | ||||
|         cli, | ||||
|         ["--host", "127.0.0.123", "--debug", "feature", "pir_range", "Far"], | ||||
|         catch_exceptions=False, | ||||
|     ) | ||||
|  | ||||
|     range_setter.assert_not_called() | ||||
|     assert "Error: Invalid value: " in res.output | ||||
|     assert res.exit_code != 0 | ||||
|  | ||||
|  | ||||
| async def test_feature_set_badquoted(mocker, runner): | ||||
|     """Test feature command's set value.""" | ||||
|     dummy_device = await get_device_for_fixture_protocol( | ||||
|         "ES20M(US)_1.0_1.0.11.json", "IOT" | ||||
|     ) | ||||
|     range_setter = mocker.patch("kasa.iot.modules.motion.Motion._set_range_cli") | ||||
|     mocker.patch("kasa.discover.Discover.discover_single", return_value=dummy_device) | ||||
|  | ||||
|     res = await runner.invoke( | ||||
|         cli, | ||||
|         ["--host", "127.0.0.123", "--debug", "feature", "pir_range", "`Far"], | ||||
|         catch_exceptions=False, | ||||
|     ) | ||||
|  | ||||
|     range_setter.assert_not_called() | ||||
|     assert "Error: Invalid value: " in res.output | ||||
|     assert res.exit_code != 0 | ||||
|  | ||||
|  | ||||
| async def test_cli_child_commands( | ||||
|     dev: Device, runner: CliRunner, mocker: MockerFixture | ||||
| ): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ryan Nitcher
					Ryan Nitcher