Python events: unable to use subroutines !
Posted: Saturday 29 April 2023 20:50
Hello,
I've been working hours on a python script outside of domoticz, which now gives me satisfaction.
Now is the time to put it in domoticz, so I copy/paste my script in the embedded Python Events editor.
And I always get the same error: (CRC being one of the subroutines I defined)
It seems the Python interpreter used by Domoticz is not able to work with subroutines ... anyone having the same issue ?
I tried to move my script to the scripts/python folder of domoticz and I get the same issue by the way.
On the same machine, if I call from cmdline it works perfectly .... I'm becoming crazy ...
So I did a simple test:
This gives me in the domotics logs:
But if I modify it like this:
This gives me in the domotics logs:
It's hard for me to believe that the Python interpreter used by domoticz is not supporting subroutines ....
I couldn't find any topic about this anywhere on this forum or on the net.
Anyone with ideas ?
Thank a lot guys !
I've been working hours on a python script outside of domoticz, which now gives me satisfaction.
Now is the time to put it in domoticz, so I copy/paste my script in the embedded Python Events editor.
And I always get the same error: (CRC being one of the subroutines I defined)
Code: Select all
2023-04-29 20:46:01.416 Error: NameError: name 'CRC' is not defined
I tried to move my script to the scripts/python folder of domoticz and I get the same issue by the way.
On the same machine, if I call from cmdline
Code: Select all
python3 script_time_myscript.py
So I did a simple test:
Code: Select all
import DomoticzEvents as DE
DE.Log("tadaaaaa")
Code: Select all
2023-04-29 20:48:28.344 tadaaaaa
Code: Select all
import DomoticzEvents as DE
def message(text):
DE.Log(text)
message("tadaaaaa")
Code: Select all
2023-04-29 20:49:40.817 Error: Traceback (most recent call last):
2023-04-29 20:49:40.817 Error: File "Script #1", line 6, in <module>
2023-04-29 20:49:40.817 Error: File "Script #1", line 4, in message
2023-04-29 20:49:40.817 Error: NameError: name 'DE' is not defined
I couldn't find any topic about this anywhere on this forum or on the net.
Anyone with ideas ?
Thank a lot guys !