Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove sleep in smarthome handler #939

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/smarthome/smartcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,4 +486,3 @@ def mainloop(wattbezug: int, speicherleistung: int, speichersoc: int) -> None:
mqtt_man[pref + 'device_manual_control'] = workman
if (sendmess == 1):
sendmq(mqtt_man)
time.sleep(5)
6 changes: 5 additions & 1 deletion packages/smarthome/smarthome.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python3
import threading
from smarthome.smartcommon import mainloop, initparam
import logging
from threading import Thread
Expand Down Expand Up @@ -42,9 +43,12 @@ def handler() -> None:
watt = SubData.counter_data[f"counter{SubData.counter_all_data.get_id_evu_counter()}"].data.get.power * -1
wattint = int(watt)
mainloop(wattint, speicherleistung, speichersoc)
# time.sleep(5)
except Exception:
log.exception("Fehler im Smarthome-Handler")
# run as thread for logging reasons
initparam(mqttcg, mqttcs, mqttsdevstat, mqttsglobstat, mqtttopicdisengageable, ramdiskwrite, mqttport)
for thread in threading.enumerate():
if thread.name == "smarthome":
log.debug("Don't start multiple instances of smarthome thread.")
return
Thread(target=handler, args=(), name="smarthome").start()