Python Scripts...What's happening here?

Python and python framework

Moderator: leecollings

Post Reply
User avatar
dpcons
Posts: 7
Joined: Wednesday 21 March 2018 4:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Python Scripts...What's happening here?

Post 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
jannl
Posts: 666
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

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

Post 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.
User avatar
waltervl
Posts: 5714
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest