A versatile and extensible platform automation, with hundreds of supported integrations https://platypush.tech
Go to file
Fabio Manganiello d75f319ea6 Removed runbullet start script, using entry_points to automatically generate the script instead 2017-11-03 22:53:55 +01:00
runbullet Removed runbullet start script, using entry_points to automatically generate the script instead 2017-11-03 22:53:55 +01:00
.gitignore gitignore 2017-11-03 12:43:18 +01:00
LICENSE.txt MIT License 2017-11-03 18:06:58 +01:00
README.md README 2017-11-03 21:33:53 +01:00
setup.py runbullet.lib.plugins moved to runbullet.plugins 2017-11-03 19:56:12 +01:00

README.md

Runbullet

Execute any command or custom complex logic on your devices, wherever they are, using your PushBullet account.

Installation

pip install runbullet

Configuration

Copy /etc/runbullet/config.example.yaml to /etc/runbullet/config.yaml (system-wise settings) or ~/.config/runbullet/config.yaml (user-wise settings).

Edit the file to include:

  • Your PushBullet access token (create one here);
  • The name of the (virtual) PushBullet device used to listen for events (create one here).

Each target device is identified by a unique device_id in the messages sent over your account. The device_id is the hostname by default, unless changed in config.yaml.

Testing

runbullet installs pusher, a command-line tool to send PushBullet messages to the connected devices in the format used by runbullet.

Some examples:

echo '{"cmd":"scp /home/user/photos/*.jpg backup_host:/mnt/hd/photos"}' | pusher --target laptop --plugin shell
echo '{"play":true}' | pusher --target raspberrypi --plugin music.mpd

Writing your plugins

Writing your own runbullet plugin, that would execute your own custom logic whenever a bullet with your plugin name is received, is a very simple task.

  1. Create your plugin directory under runbullet/plugins (e.g. light/batsignal).

  2. In the case above, runbullet.plugins.light.batsignal will be your package name.

  3. Create an __init__.py under runbullet/plugins/light/batsignal.

  4. If your module is light/batsignal, then its main class should be named LightBatsignalPlugin.

  5. The configuration for your module will be read from a section named light.batsignal from your config.yaml, the attributes are accessible in your class in self.config.

The __init__.py will look like this:

from .. import LightPlugin

class LightBatsignalPlugin(LightPlugin):
    def _init(self):
        self.batsignal = batsignal.Batsignal(self.config['intensity'])

    def on(self):
        self.batsignal.on()

    def off(self):
        self.batsignal.off()

    def toggle(self):
        self.batsignal.toggle()

    def status(self):
        return [self.batsignal.status().stdout, self.batsignal.status().stderr]
  1. It's a good practice to define a status method in your plugin, which returns a 2-items list like [output, error].

  2. Rebuild and reinstall runbullet if required and relaunch it.

  3. Test your new plugin by sending some bullets to it:

echo '{"on":true}' | pusher --target your_pc --plugin light.batsignal