frelev
June 19, 2017, 7:27pm
1
I have a command line switch like this
switch:
platform: command_line
switches:
monitor_maverick:
command_on: /home/pi/maverick_start.sh
command_off: /home/pi/maverick_stop.sh
“On” works as it should but Off gives me an error message:
Stop Maverick Reporter
Terminated
2017-06-19 21:18:19 ERROR (Thread-6) [homeassistant.components.switch.command_line] Command failed: /home/pi/maverick_stop.sh
It does however what it should (kill the process and writes to file) but the switch doesn´t change status due to the error.
Running maverick_stop.sh manually from bash works fine with the same user (pi).
script;
#!/bin/bash
# Script to start our application
echo "Stop Maverick Reporter"
echo "{\"Food\": 0, \"BBQ\": 0 }" >> /home/pi/Maverick/log.txt
sudo /usr/bin/pkill maverick > /dev/null 2>&1
Anyone got an idea to get HASS not to report ERROR and turn the switch?
RobDYI
June 19, 2017, 9:10pm
2
I am surprised that the stop.sh works while giving an error. If it didn’t work, I would check that there is no white space behind the command.
treno
(travis reno)
June 19, 2017, 9:10pm
3
what happens if you add this as the list line of the script:
exit 0
frelev
June 20, 2017, 5:41pm
4
Unfortunately no change.
It still gives me the error in HASS
RobDYI
June 20, 2017, 6:05pm
6
Can you change the maverick_stop.sh script to something that you know works like the script to start.sh? That way we can determine if its the script or HA.
edit: I altered one of my script to garbage and got the same error as you.
frelev
June 20, 2017, 6:11pm
7
If I exclude the line that kills the process it works:
sudo /usr/bin/pkill maverick > /dev/null 2>&1
But I need to kill the process somehow…
Also, it works to run the .sh outside hass without error
RobDYI
June 20, 2017, 6:15pm
8
Ok, I don’t know why that line doesn’t work. A similar problem here was solved by dropping the sudo.
Thanks a ton @silvrr , that seemed to be the problem. I just had to drop “sudo” from my commands and now they work great under user hass in terminal.
A different problem appeared now in Home Assistant. When I turn command switch on, it doesn’t stay on. After a few seconds it automatically switches itself to ‘off’ position and it doesn’t trigger the off command. So if I check in terminal, my program, which was started when I turned my switch on is still running.
The switch would just have to sta…
frelev
June 20, 2017, 6:22pm
9
Thanks for the suggestion but dropping sudo gives me error again
Stop Maverick Reporter
Terminated
2017-06-20 20:22:21 ERROR (Thread-8) [homeassistant.components.switch.command_line] Command failed: /home/pi/maverick_stop.sh