pponce/homebridge-script2

Applescript

Closed this issue · 4 comments

leovj commented

Hello and thanks for the plug in!
I can't run an apple script...
{ "accessory": "Script2", "name": "Telecamere", "on": "/Users/leo/Desktop/Scripts/ArmaTelecamere.scpt", "off": "/Users/leo/Desktop/Scripts/DisarmaTelecamere.scpt" }
It gives no errors, but it doesn't work.
Where am I doing wrong?
Thank you

leovj commented

I have try to create a file .sh whit this text:
osascript /Users/leo/Desktop/Scripts/ArmaTelecamere.scpt
if I try to launch the file by double clicking on it it works and launches the apple script correctly.

I Have add this in JSON:
{
"accessory": "Script2",
"name": "Telecamere",
"on": "/Users/leo/Desktop/Scripts/ArmaTelecamere.sh",
"off": "/Users/leo/Desktop/Scripts/DisarmaTelecamere.sh"
}

The switch appears on homekit and turns on, but nothing happens..
This is the homebridge log:
10/9/2020, 16:38:25 [Telecamere] Set Telecamere to on

Can anyone help me?

Can you check your scripts and see if they work when executed as the same user that you use to run homebridge?

You have to make sure the homebridge user has the access rights to the script And any commands you execute within the script. Also make any paths in the script the full path to the commands.

Those are a couple of pointers.
I’d Also ask that you take a look at the closed out issues for this project. You may find some other advice from other users of the plugins that have had some issues executing their scripts.

leovj commented

I found the solution! The script I created was going to arm the cameras, that is, interacting with a program that runs under the leo user. Instead, the script was run under the root user. Just add sudo -u user to the script before the command and everything works! Thank you

Glad you figured it out.

Confirming user permissions by testing the script with the same user as homebridge is run with and full path to all executables solves most of the issues I’ve seen thus far from people. I had a feeling it would be one of those for you.