python-miio sh script did not execute in domoticz / SOLVED

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Post Reply
d3smo
Posts: 19
Joined: Friday 29 May 2015 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

python-miio sh script did not execute in domoticz / SOLVED

Post by d3smo »

Hi all,

I've install python-miio on my domoticz RPi i've get the token and everything. I've create a sh script mirobotStart.sh like that

Code: Select all

#!/bin/bash
miiocli roborockvacuum --model rockrobo.vacuum.v1 --ip 192.168.1.32 --token 5061---------------------366f start
and when i execute the script from ssh terminal with ./mirobotStart.sh it works, my vaccum robot start

I've then create a dummy switch in domoticz and on "Action On:" i fill the following command

script:///home/pi/domoticz/scripts/Xiaomi/mirobotStart.sh

When i activate the dummy switch the log told me that

Code: Select all

2022-11-30 18:44:05.371 Status: User: Admin (IP: 192.168.1.18) initiated a switch command (356/Xiaomi Robot/On)
2022-11-30 18:44:05.596 Status: Executing script: /home/pi/domoticz/scripts/Xiaomi/mirobotStart.sh
2022-11-30 18:44:05.614 Error: Error executing script command (/home/pi/domoticz/scripts/Xiaomi/mirobotStart.sh). returned: 32512
I've made a chmod+X on the script and the right are the followings

Code: Select all

-rwxrwxrwx  1 pi pi  153 Nov 30 16:00 mirobotStart.sh
Is there anyone to help me on that ?
Last edited by d3smo on Friday 02 December 2022 23:33, edited 1 time in total.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: python-miio sh script did not execute in domoticz

Post by waltervl »

Domoticz probably runs with elevated rights so to test you should run the test script with sudo and see what the error is.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
d3smo
Posts: 19
Joined: Friday 29 May 2015 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: python-miio sh script did not execute in domoticz

Post by d3smo »

Thx for you reply, i begin to understand the script works only if i launch it as pi user, and as domoticz launch the scripts as root user it did not work. How can i found a turnaround ?
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: python-miio sh script did not execute in domoticz

Post by waltervl »

Solve the problem why it is not running as root.
You probably have to enter the full path to miiocli in the bash script eg /home/pi/miiocli
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
ferrosk
Posts: 44
Joined: Saturday 26 August 2017 20:13
Target OS: Linux
Domoticz version: 2023.2
Contact:

Re: python-miio sh script did not execute in domoticz

Post by ferrosk »

if domoticz is running as root and you need execute the command as 'pi' user you can try modify the script:

Code: Select all

#!/bin/bash
sudo -u pi miiocli roborockvacuum --model rockrobo.vacuum.v1 --ip 192.168.1.32 --token 5061---------------------366f start
Domoticz 2023.2 on Odroid M1 and Armbian
MySensors (RFM69 Serial GW): bunch of DIY sensors/devices
Zwave (Z-Wave.me RaZberry board): Danfoss devices
Zigbee (Sonoff Dongle Plus): IKEA, Tesla devices
d3smo
Posts: 19
Joined: Friday 29 May 2015 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: python-miio sh script did not execute in domoticz

Post by d3smo »

Thx for the help, it's not solve but we are approching, to figure out what the error was i connect to ssh as root and execute the script to check the errors

So with the first solution exec it as pi user he is the error

Code: Select all

root@domoticzPi3:/home/pi# sudo -u pi miiocli roborockvacuum --model rockrobo.vacuum.v1 --ip 192.168.1.32 --token 50---------------------------6366f start
sudo: miiocli: command not found
And with the path en other error, it seems another process need also the path

Code: Select all

root@domoticzPi3:/home/pi# /home/pi/.local/bin/miiocli roborockvacuum --model rockrobo.vacuum.v1 --ip 192.168.1.32 --token 50615857436c4e4f795971576166366f start &
[1] 1128
root@domoticzPi3:/home/pi# Traceback (most recent call last):
  File "/home/pi/.local/bin/miiocli", line 5, in <module>
    from miio.cli import create_cli
ModuleNotFoundError: No module named 'miio'
^C
[1]+  Exit 1                  /home/pi/.local/bin/miiocli roborockvacuum --model rockrobo.vacuum.v1 --ip 192.168.1.32 --token 50--------------------------66f start
d3smo
Posts: 19
Joined: Friday 29 May 2015 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: python-miio sh script did not execute in domoticz

Post by d3smo »

IT WORKS solution 1 + 2 works !

Code: Select all

root@domoticzPi3:/home/pi# sudo -u pi /home/pi/.local/bin/miiocli roborockvacuum --model rockrobo.vacuum.v1 --ip 192.168.1.32 --token 506------------------------6f start
Thx guys
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest