homebridge-script icon indicating copy to clipboard operation
homebridge-script copied to clipboard

incompatible with file-exists 3.0.1

Open KangKai1982 opened this issue 8 years ago • 14 comments

after update file-exists package to the latest version 3.0.1, homebridge-script stopped working.

KangKai1982 avatar Feb 12 '17 15:02 KangKai1982

I submitted a pull request for a quick fix for this. But not sure if this package is being maintained any more. Feel free to install my fork. it should work with the latest file-exists pponce/homebridge-script

pponce avatar Feb 18 '17 23:02 pponce

How can I install your fork?

llfjahn avatar Mar 10 '17 14:03 llfjahn

You can simply replace the index.js file with pponce's version.

KangKai1982 avatar Mar 10 '17 15:03 KangKai1982

Thank you for the fast reply. I still don't get it to work. Switching it on it does not run my script. But when turning the switch off it runs the off script. How exactly I need to configure this?

 "on": "~/on.sh", <- Path to script when turning the switch on ?
 "off": "~/off.sh", <- Path to script when turning the switch off ?
 "state": "~/state.sh", <- Path to state script? Which states should it send? true and false?
 "fileState": "/Users/olegmalovichko/script.flag", <- Whats that?
 "on_value" : "true",  <- Whats that?
 "exact_match": true  <- Whats that?

llfjahn avatar Mar 10 '17 16:03 llfjahn

On and Off works now. Had a typo. But I still don't understand how it should work with the state..

llfjahn avatar Mar 10 '17 16:03 llfjahn

To install my fork you can do npm install -g homebridge-script2

I'm not sure what on_value or exact match do. I left them set at true. When a homekit app checks for current state, it uses the existence of the filestate file that you configure. If it exists, it's on. If not, it's off. Make sure your on.sh script creates the configured filestate file. And that your off script rm's your configured filestate file. I don't see in the code where the state.sh script executes. So it probably does not. But I kept the state script that comes with the repo and point to it in my config. I use my on.sh, off.sh scripts. They create and remove the filestate configured file. Things work just fine like this.

pponce avatar Mar 10 '17 19:03 pponce

Ah thank you, thats how it woks! Is it maybe possible to edit the code to let the status script run if home kit ask for a status?

llfjahn avatar Mar 11 '17 09:03 llfjahn

Probably. I'm a bit of hack coder. Let me give it a go in my fork.

pponce avatar Mar 11 '17 22:03 pponce

Can you help me with the state.sh ? You write that we should output to stdout. I'm pretty new to all of this. How das this work ? I thought something like this echo "true" 2>&1 ?

llfjahn avatar Mar 12 '17 12:03 llfjahn

ah forget it! I just had an oder version. Had to manually copy the index.js to the file. Installing with npm install -g pponce/homebridge-script got me an older version.

Now it works great! Thank you very much!

llfjahn avatar Mar 12 '17 13:03 llfjahn

Actually you got the new update with working state.sh. I updated it pretty much after my comment and updated the read-me. Had not had time to test it though. Glad it works. Let me know if you run into issues. Running: npm install -g homebridge-script2 should always get you the latest version.

pponce avatar Mar 12 '17 15:03 pponce

@MeinMilchKaffee Let me know if everything is working well with my changes and using state.sh.

pponce avatar Mar 13 '17 17:03 pponce

I hadn't time today to test it. I will try it tomorrow and keep you updated.

llfjahn avatar Mar 13 '17 23:03 llfjahn

Installed 0.0.9. Works great!

llfjahn avatar Mar 14 '17 07:03 llfjahn