Page 1 of 1

Python Scripts...What's happening here?

Posted: Thursday 03 April 2025 0:59
by dpcons
I'm new to scripts, s0 I tried this simple one, based on an example online:
I'm using the Setup>More Optionsa>Events tab and creating the script there.

import domoticz
import DomoticzEvents as DE

if DE.changed_device_name == "Processor Temperature":
if DE.Devices["Processor Temperature"].s_value != 0:
domoticz.log("This is a test log entry")

when it runs, nothing happens.
if i use a different temp sensor, shown below

import domoticz
import DomoticzEvents as DE

if DE.changed_device_name == "Crawl Space":
if DE.Devices["Crawl Space"].s_value != 0:
domoticz.log("This is a test log entry")

...it runs but I get this error:
PyDomoticz_EventsLog: Invalid parameter, expected single parameter, got 2 parameters

The script is identical, except the device name.
any help would be appreciated!
Dan

Re: Python Scripts...What's happening here?

Posted: Thursday 03 April 2025 8:17
by jannl
I do not know a lot about Python (yet), however, I do know Python is depending on indents, I do not see any indents in your piece of code, could that be the problem?

And it would be more readable when you use the code brackets for displaying snippets of (python)code.

Re: Python Scripts...What's happening here?

Posted: Thursday 03 April 2025 10:49
by waltervl
If you start working with scripts in Domoticz please invest some time to use Dzvents instead of Python. Much better integration and documentation: https://wiki.domoticz.com/DzVents:_next ... _scripting