Script python: Error executing script command .... returned: 256 Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
Pchatill
Posts: 36
Joined: Wednesday 16 September 2015 5:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v2026.2
Location: France
Contact:

Script python: Error executing script command .... returned: 256

Post by Pchatill »

Hi everydody.
I try to work with a python script find on:
But it doens't works

Code: Select all

DE.Log("Python: Changed: " + DE.changed_device.Describe())

if DE.changed_device_name == "Test":
    if DE.Devices["Test_Target"].n_value_string == "On":
        DE.Command("Test_Target", "Off")

    if DE.Devices["Test_Target"].n_value_string == "Off":
        DE.Command("Test_Target", "On")

DE.Log("Python: Number of user_variables: " + str(len(DE.user_variables)))

# All user_variables are treated as strings, convert as necessary
for key, value in DE.user_variables.items():
    DE.Log("Python: User-variable '{0}' has value: {1}".format(key, value))

# Description of Device_object should go here...
If I run this script with Domoticz (Setup/More options/Events) then everything is OK

But if I want to run with the graphical interface (I mean Switch/Edit Device:script://essai1.py)
Then I have the error: Script python: Error: Error executing script command .... returned: 512
If I add the shebang !/usr/bin/env python3 th error became 256.

If I run the script in the terminal then I have:
File "/home/pchatill/domoticz/scripts/python/./essai1.py", line 3, in <module>
import DomoticzEvents as DE
ModuleNotFoundError: No module named 'DomoticzEvents'
I looked on the forum but I didn't find a solution.
Any idea?

Thanks for helping
User avatar
waltervl
Posts: 7020
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2026.3
Location: NL
Contact:

Re: Script python: Error executing script command .... returned: 256

Post by waltervl »

When running a python script as an action script on a device/switch it is not an eventscript and Domoticz events integration is not working.

The action scripts are normally used to control something outside Domoticz and no integration with Domoticz is supported.
If you want to control something inside Domoticz you need to use an eventscript as you did before.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Pchatill
Posts: 36
Joined: Wednesday 16 September 2015 5:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v2026.2
Location: France
Contact:

Re: Script python: Error executing script command .... returned: 256

Post by Pchatill »

That's clear!!
Thanks a lot for the answer waltervl!
Post Reply