mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-04-26 16:46:23 +00:00
Add reboot and factory_reset to tapodevice (#686)
* Add reboot and factory_reset to tapodevice * Add test for reboot command * Fix mocking as different protocols use different methods for comms..
This commit is contained in:
parent
cfbdf7c64a
commit
c8ac3a29c7
@ -339,3 +339,18 @@ class TapoDevice(SmartDevice):
|
||||
"time": t,
|
||||
}
|
||||
return await self.protocol.query({"set_qs_info": payload})
|
||||
|
||||
async def reboot(self, delay: int = 1) -> None:
|
||||
"""Reboot the device.
|
||||
|
||||
Note that giving a delay of zero causes this to block,
|
||||
as the device reboots immediately without responding to the call.
|
||||
"""
|
||||
await self.protocol.query({"device_reboot": {"delay": delay}})
|
||||
|
||||
async def factory_reset(self) -> None:
|
||||
"""Reset device back to factory settings.
|
||||
|
||||
Note, this does not downgrade the firmware.
|
||||
"""
|
||||
await self.protocol.query("device_reset")
|
||||
|
@ -21,6 +21,7 @@ from kasa.cli import (
|
||||
cli,
|
||||
emeter,
|
||||
raw_command,
|
||||
reboot,
|
||||
state,
|
||||
sysinfo,
|
||||
toggle,
|
||||
@ -103,6 +104,21 @@ async def test_raw_command(dev):
|
||||
assert "Usage" in res.output
|
||||
|
||||
|
||||
@device_smart
|
||||
async def test_reboot(dev, mocker):
|
||||
"""Test that reboot works on SMART devices."""
|
||||
runner = CliRunner()
|
||||
query_mock = mocker.patch.object(dev.protocol, "query")
|
||||
|
||||
res = await runner.invoke(
|
||||
reboot,
|
||||
obj=dev,
|
||||
)
|
||||
|
||||
query_mock.assert_called()
|
||||
assert res.exit_code == 0
|
||||
|
||||
|
||||
@device_smart
|
||||
async def test_wifi_scan(dev):
|
||||
runner = CliRunner()
|
||||
|
Loading…
x
Reference in New Issue
Block a user