Add reboot() to the device interface (#1124)

Both device families have already had a method following this signature,
but defining the interface in the base class will make the contract
clear.
This commit is contained in:
Teemu R. 2024-09-21 16:37:38 +02:00 committed by GitHub
parent 5df6c769b8
commit f07341a5a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -449,6 +449,14 @@ class Device(ABC):
async def set_alias(self, alias: str):
"""Set the device name (alias)."""
@abstractmethod
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.
"""
def __repr__(self):
if self._last_update is None:
return f"<{self.device_type} at {self.host} - update() needed>"