Skip to content

A homebridge switch which changes state only if the shell command is successful.

License

Notifications You must be signed in to change notification settings

cr3ative/homebridge-shell-switch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

homebridge-shell-switch

A homebridge switch which changes state only if the shell command is successful. Shows pending state while command is being run.

But why?

Suppose you to run a bash script on your homebridge host system, but it isn't guaranteed to work. You want to retry that command in a little while until it works.

  • This switch won't change state until the script returns a successful exit code (zero).
  • If anything else happens, the switch will remain in its previous state.
  • We'll show the "pending" switch state while the command is running.

The switch will maintain state between homebridge reboots, using node-persist, except for those switches marked as stateless by setting stateful to false. Those switches are always showing state as ON and thus only the onCmd is executed. The offCmd is ignored. Usefull e.g. for rebooting your router via shell command. Default stateful is true.

Many thanks to hans-1 for providing a lovely base for this plugin to grow on.

Installation

Example config.json:

    "accessories": [
        {
            "accessory": "ShellSwitch",
            "name": "TV Power",
            "onCmd": "/home/homebridge/control/tv_on.sh",
            "offCmd": "/home/homebridge/control/tv_off.sh",
            "stateful" : true
        }
    ]

About

A homebridge switch which changes state only if the shell command is successful.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%