FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add reboot and factory_reset to tapodevice by rytilahti · Pull Request #686 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 15 additions & 0 deletions kasa/tapo/tapodevice.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,18 @@ async def update_credentials(self, username: str, password: str):
"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")
16 changes: 16 additions & 0 deletions kasa/tests/test_cli.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
cli,
emeter,
raw_command,
reboot,
state,
sysinfo,
toggle,
Expand Down Expand Up @@ -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()
Expand Down

Back | FazBrowse Home | New Git URL