Add factory_reset() to iotdevice (#1125)

Also extend the base device class API to make factory_reset() part of the common API.
This commit is contained in:
Teemu R. 2024-09-27 18:42:22 +02:00 committed by GitHub
parent d1b43f5408
commit 1ce5af2494
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -457,6 +457,13 @@ class Device(ABC):
as the device reboots immediately without responding to the call. as the device reboots immediately without responding to the call.
""" """
@abstractmethod
async def factory_reset(self) -> None:
"""Reset device back to factory settings.
Note, this does not downgrade the firmware.
"""
def __repr__(self): def __repr__(self):
if self._last_update is None: if self._last_update is None:
return f"<{self.device_type} at {self.host} - update() needed>" return f"<{self.device_type} at {self.host} - update() needed>"

View File

@ -561,6 +561,13 @@ class IotDevice(Device):
""" """
await self._query_helper("system", "reboot", {"delay": delay}) await self._query_helper("system", "reboot", {"delay": delay})
async def factory_reset(self) -> None:
"""Reset device back to factory settings.
Note, this does not downgrade the firmware.
"""
await self._query_helper("system", "reset")
async def turn_off(self, **kwargs) -> dict: async def turn_off(self, **kwargs) -> dict:
"""Turn off the device.""" """Turn off the device."""
raise NotImplementedError("Device subclass needs to implement this.") raise NotImplementedError("Device subclass needs to implement this.")