Fix fan reset on resume from sleep
This commit is contained in:
parent
088acc4301
commit
d7b63fe64f
1 changed files with 7 additions and 0 deletions
7
main.py
7
main.py
|
@ -1,6 +1,7 @@
|
|||
import json
|
||||
import os
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
import logging
|
||||
|
||||
|
@ -179,8 +180,14 @@ class Plugin:
|
|||
self.settings["curve"] = DEFAULT_DATA["curve"]
|
||||
self.is_changed = True
|
||||
on_set_enable(self.settings["enable"])
|
||||
last_time = time.time()
|
||||
# work loop
|
||||
while True:
|
||||
if (time.time() - last_time) * 0.9 > self.period_s:
|
||||
# detect sleep
|
||||
logging.debug("Detected resume from sleep, overriding fan again")
|
||||
on_set_enable(self.settings["enable"])
|
||||
last_time = time.time()
|
||||
if self.is_changed:
|
||||
self.save(self)
|
||||
self.is_changed = False
|
||||
|
|
Loading…
Reference in a new issue