| runbullet | ||
| .gitignore | ||
| LICENSE.txt | ||
| README.md | ||
| setup.py | ||
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.
Shell interface
runbullet installs pusher, a command-line tool to send PushBullet messages to the connected devices in the format used by runbullet.
Some examples:
pusher --target laptop --action shell.exec --cmd "scp /home/user/photos/*.jpg backup_host:/mnt/hd/photos"
pusher --target raspberrypi --action music.mpd.play
The logic to execute is specified by the --action option, whose format is package_name.method_name (with method_name part of the package main class).
Available plugins
runbullet.plugins.shell: The simplest and yet most versatile plugin. Executes a remote command on the host identified by the--targetdevice_id. Example:
pusher --target laptop --action shell.exec --cmd "scp /home/user/photos/*.jpg backup_host:/mnt/hd/photos"
runbullet.plugins.music.mpd: Controls the playback on a mpd/mopidy music server. Requires the packagempd2on the target machine. Example:
pusher --target raspberry --action music.mpd.play
Configure the plugin through an entry like this in your config.yaml:
music.mpd:
host: your_mpd_host
port: 6600
runbullet.plugins.switch.wemo: Controls a WeMo Switch smart switch device. Requires the packageouimeauxon the target machine. Example:
pusher --target raspberry --action switch.wemo.on
- TODO
runbullet.plugins.light.hue: Controls a Philips Hue smart lights system. Requires the packagephueon the target machine. Example:
pusher --target raspberry --action light.hue.set_scene --scene "Sunset" --group "Living Room"
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.
-
Create your plugin directory under
runbullet/plugins(e.g.light/batsignal). -
In the case above,
runbullet.plugins.light.batsignalwill be your package name. -
Create an
__init__.pyunderrunbullet/plugins/light/batsignal. -
If your module is
light/batsignal, then its main class should be namedLightBatsignalPlugin. -
The configuration for your module will be read from a section named
light.batsignalfrom yourconfig.yaml, the attributes are accessible in your class inself.config.
The __init__.py will look like this:
import batman
from .. import LightPlugin
class LightBatsignalPlugin(LightPlugin):
def _init(self):
self.batsignal = batman.Batsignal(self.config['intensity'])
def on(self, urgent=False):
if urgent:
self.batsignal.notify_robin()
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]
-
It's a good practice to define a
statusmethod in your plugin, which returns a 2-items list like[output, error]. -
Rebuild and reinstall
runbulletif required and relaunch it. -
Test your new plugin by sending some bullets to it:
pusher --target your_pc --action light.batsignal.on --urgent 1