Shell path to python in Docker Domoticz

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
ajay100
Posts: 73
Joined: Monday 07 August 2017 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Victoria, Australia
Contact:

Shell path to python in Docker Domoticz

Post by ajay100 »

Hi all, recently a custom script stopped working in Domoticz Version: 2025.1 (build 16739) running in Docker. It is run with the command: 'script://exec_hs110.sh kp1151 on'. The Domoticz log was showing the script was activated, but it wasn't turning the device on or off.

Code: Select all

#!/bin/sh
/usr/bin/python /opt/domoticz/userdata/scripts/python/hs110_domoticz.py -d $1 -c $2 > /dev/null 2>&1 &
To troubleshoot from the Domoticz shell in docker, I ran the following from the Linux command prompt:
docker exec -it domoticz sh
sh -xv userdata/scripts/exec_hs110.sh kp1151 off

This was just printing the contents of the script, but not showing any errors. So I ran the python command directly:
/usr/bin/python /opt/domoticz/userdata/scripts/python/hs110_domoticz.py -d kp1151 -c off

At last I got an error!
sh: /usr/bin/python: No such file or directory

I then tried this command, without the path to python:
python /opt/domoticz/userdata/scripts/python/hs110_domoticz.py -d kp1151 -c off
Success!

Is this now the correct way to use python from Docker Domoticz and would you like me to document this for https://wiki.domoticz.com/Scripting_in_ ... ts_scripts?

Cheers - Andrew
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Shell path to python in Docker Domoticz

Post by waltervl »

This is general linux knowledge. Although normally Python resides in /usr/bin/ it is not obligatory and depends on the linux distro.
Use the following command to find the correct path to python:

Code: Select all

which python
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: No registered users and 1 guest