mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Add reboot command to restart the device (#129)
This commit is contained in:
parent
d72b47c0b7
commit
345216e245
@ -255,5 +255,13 @@ def off(plug):
|
||||
plug.turn_off()
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option("--delay", default=1)
|
||||
@pass_dev
|
||||
def reboot(plug, delay):
|
||||
"""Reboot the device."""
|
||||
click.echo("Rebooting the device..")
|
||||
plug.reboot(delay)
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
@ -513,6 +513,17 @@ class SmartDevice(object):
|
||||
response = EmeterStatus(self.get_emeter_realtime())
|
||||
return response['power']
|
||||
|
||||
def reboot(self, delay=1) -> None:
|
||||
"""
|
||||
Reboot the device.
|
||||
|
||||
:param delay: Delay the reboot for `delay` seconds.
|
||||
:return: None
|
||||
|
||||
Note that giving a delay of zero causes this to block.
|
||||
"""
|
||||
self._query_helper("system", "reboot", {"delay": delay})
|
||||
|
||||
def turn_off(self) -> None:
|
||||
"""
|
||||
Turns the device off.
|
||||
|
Loading…
Reference in New Issue
Block a user