luisiam / homebridge-cmdswitch2

CMD Plugin for HomeBridge (API 2.0): https://github.com/nfarina/homebridge
Apache License 2.0
176 stars 29 forks source link

Native directory of cmdswitch2 with hb-service and homebridge user #58

Open bencharlesrhys opened 4 years ago

bencharlesrhys commented 4 years ago

I'm having issues with this plugin now I've updated to v1.0.2 Homebridge and using the hb-service with homebridge user rather than systemd. Worked previously, and my other cmdtrigger plugin is working fine using these script files.

Can someone confirm the working directory being used by the plugin?

I've copied the files from /home/pi/ to /var/lib/homebridge: on.sh off.sh state.sh

config.json:

{
            "platform": "cmdSwitch2",
            "name": "CMD Switch",
            "switches": [
                {
                    "name": "Apartment Door Buzzer",
                    "on_cmd": "./on.sh",
                    "off_cmd": "./off.sh",
                    "state_cmd": "./state.sh"
                }
            ]
        }

state.sh

#!/bin/bash

gpio mode 0 out
gpio read 0

on.sh

#!/bin/bash

gpio mode 0 out
gpio write 0 1

off.sh

#!/bin/bash

gpio mode 0 out
gpio write 0 0