Open lybserv2 opened 1 year ago
Unfortunately, you still need to preface the command with "sh" as there is no environment settings in the exec from the system. Try "sh /home/pi/ac_off.sh"
I had the same problem, did not matter if I executed it directly or as script or as systemctl service. Nothing worked. The solution was my service wanted to run as user and not root. But my ha-bridge was started as root and not user.
Check if midea-beautiful-air-cli has to be executed as user and if yoa ure running ha-bridge as root. Both together does not work, at least in my example.
You can run ha-bridge as user if you set the port outside of the privileged port range (1-1023):
java -jar -Dserver.port=31337 ha-bridge-v5.4.1.jar http://YourIP:31337
Edit:
Ok but with a port other than 80, Alexa could not find my ha-bridge devices. Now I was in a dilemma, my commadn which I launch through the script only works as user but I can not launch ha-bridge as user. The solution was to give java the rights to run it on port 80 as user:
sudo apt-get install libcap2-bin sudo setcap cap_net_bind_service=+ep $(readlink -f java) java -jar ha-bridge-v5.4.1.jar
Maybe this helps someone. I just want to make it clear again, the script itself running within ha-brdige was not my problem. The problem was the command in the script had to be run as user.
Edit:
Ok but with a port other than 80, Alexa could not find my ha-bridge devices. Now I was in a dilemma, my commadn which I launch through the script only works as user but I can not launch ha-bridge as user. The solution was to give java the rights to run it on port 80 as user:
Maybe this helps someone. I just want to make it clear again, the script itself running within ha-brdige was not my problem. The problem was the command in the script had to be run as user.
I actually ran into both these issues a few weeks ago. I moved HA-Bridge to port 85 so I could free up 80 for something else. Wrong! Broke pretty much everything. Then I had set up a script to control an Onkyo receiver. Could not make it work at all until I changed the commands WITHIN the script to run as su -c "command" username
I use they x-10 heyu software to operate lots of things, and if I assigned an operation that wasn't part of they heyu (like irclient from irtrans) into a heyu alias, I found it called any shell/script, avoiding the "sh" thing.
I presume heyu adds a shell.
trying to run a shell script via execute command, i tried like everything and cant get it to work
i type in "/home/pi/ac_off.sh" in the execute command section.
ac_off.sh contains:
!/bin/sh
/home/pi/.local/bin/midea-beautiful-air-cli set --ip 192.168.2.70 --token xxx --key xxx --running 0
It wont execute it, chmod +x is set, tried with root and pi user, tried with sh and /bin/sh in front of the command.. nothing. HaBridge shows no error, it says the command is executed successfully. I got another device in habridge which controls my hyperion ambilight with "/home/pi/hyperion/build/bin/hyperion-remote --on" for example, this works flawlessly.
If i put the hyperion command in the shell script it doesnt work, too. So it has something to do with sh scripts itself?
Would be happy for a hint, cheers!