Page 1 of 1

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

Posted: Wednesday 30 November 2022 19:56
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 ?

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

Posted: Wednesday 30 November 2022 22:24
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.

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

Posted: Friday 02 December 2022 12:14
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 ?

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

Posted: Friday 02 December 2022 14:51
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

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

Posted: Friday 02 December 2022 14:55
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

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

Posted: Friday 02 December 2022 15:54
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

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

Posted: Friday 02 December 2022 15:57
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