pponce / homebridge-script2

Execute custom scripts via HomeKit apps
89 stars 18 forks source link

fileState problem with path "~/" #20

Closed ghost closed 4 years ago

ghost commented 5 years ago

Hi,

it seems doesn't work very well when you have config.json like this:

"fileState": "~/script.flag",

if you TURN ON the "accessory" and after you enter in Home app with another device the "button" will going to turn off immediately in both device but the script is still running.

no problem if you use full path:

"fileState": "/home/$USER/script.flag",

pponce commented 5 years ago

The scripts execute using the homebridge user. In my case i have a user named "homebridge" that runs my homebridge instance. So "~/" corresponds to the homebridge users home directory. Using the full path though avoids any issues.

ghost commented 5 years ago

make sense, but it’s strange because the other “fields” don’t have that problem (like on/off) only fileState needs full path. my user is Pi and I lunch homebridge with it.

pponce commented 4 years ago

Looks like the file-exists function has issues with the shortcut “~” for the users home folder. I updated the readme to call out we need the full path and can’t use the ~ shortcut.