Add reboot command to restart the device (#129)

This commit is contained in:
Teemu R 2018-09-08 16:11:58 +02:00 committed by GitHub
parent d72b47c0b7
commit 345216e245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -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()

View File

@ -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.