Add support of DomoticzEx

This commit is contained in:
2024-12-15 22:38:11 +01:00
parent 8403909c43
commit b0bbc8c8c0
2 changed files with 229 additions and 1 deletions

7
run.py
View File

@@ -3,6 +3,7 @@
import os
import time
import Domoticz
import DomoticzEx
def function_read_properties(filename:str, sep:str='=', comment_char:str='#')->dict:
"""Convert a .properties file into a dictionary"""
@@ -35,6 +36,7 @@ Parameters = function_read_properties(os.path.join(os.path.dirname(__file__), "p
Images = Domoticz.Images
Devices = Domoticz.Devices
DomoticzEx.Devices = Devices #Domoticz and DomoticsEx share the same "Devices"
with open("./plugin.py", 'rb') as fileobj:
exec(compile(fileobj.read(), "plugin.py", 'exec'), globals(), globals()) #pylint: disable=exec-used
@@ -47,4 +49,7 @@ try:
onHeartbeat() #pylint: disable=undefined-variable # type: ignore
time.sleep(Domoticz.domo.GetHeartbeat())
finally:
onStop() #pylint: disable=undefined-variable # type: ignore
try:
onStop() #pylint: disable=undefined-variable # type: ignore
except NameError:
pass