Auto auto-off module for smartdevice (#760)

Adds auto-off implementation. The feature stays enabled after the timer runs out, and it will start the countdown if the device is turned on again without explicitly disabling it.

New features:
* Switch to select if enabled: `Auto off enabled (auto_off_enabled): False`
* Setting to change the delay: `Auto off minutes (auto_off_minutes): 222`
* If timer is active, datetime object when the device gets turned off: `Auto off at (auto_off_at): None`
This commit is contained in:
Teemu R
2024-02-19 21:11:11 +01:00
committed by GitHub
parent 44b59efbb2
commit efb4a0f31f
5 changed files with 90 additions and 1 deletions

View File

@@ -47,4 +47,5 @@ class Feature:
"""Set the value."""
if self.attribute_setter is None:
raise ValueError("Tried to set read-only feature.")
return await getattr(self.device, self.attribute_setter)(value)
container = self.container if self.container is not None else self.device
return await getattr(container, self.attribute_setter)(value)