Added Pushbullet backend wiki entry

Fabio Manganiello 2018-07-24 01:11:26 +02:00
parent c45fbedbc3
commit a115a6d648
2 changed files with 184 additions and 1 deletions

@ -408,6 +408,189 @@ You can now start sending messages to your backend through the [MQTT plugin](plu
[Backend reference](https://platypush.readthedocs.io/en/latest/platypush/backend/pushbullet.html)
[Pushbullet](https://www.pushbullet.com/) is a quite cool piece of software to keep your devices in sync, exchange messages, synchronize clipboards and sms across devices, access remote files, and so on. You can install it as an Android or iPhone app, as a browser extension, or use it from your browser directly. It can be quite powerful if paired with Platypush - and it has the first backend I have developed as well. You can use the plugin in pair with the backend to do things like:
* Send URLs, text and Platypush messages to your Android devices
* Trigger Platypush actions through your Android device, wherever you are
* Synchronize the clipboards
* Synchronize your phone notifications to your Raspberry Pi
* Send and receive pictures
* ...and so on
To integrate your Pushbullet events with Platypush:
1. Sign up or login to [Pushbullet](https://pushbullet.com)
2. Create an [API token](https://www.pushbullet.com/#settings)
3. Register the device you want to synchronize with Platypush - download the Pushbullet app on your Android or iOS device, or install the browser extension
4. Enable the extra features you wish to have on your Pushbullet account - e.g. universal copy&paste to keep the clipboards in sync also with your Platypush devices, remote file access etc.
5. Configure your Pushbullet backend on Platypush:
```yaml
backend.pushbullet:
token: YOUR_PUSHBULLET_TOKEN
device: platypush # Name of your Platypush virtual device on Pushbullet
```
Restart Platypush and perform some events that generate Pushbullet messages - try to send a note or a picture to your virtual Platypush device, get a notification on your Android phone or dismiss a notification, copy some text or URL if you enabled the universal copy&paste feature. You should be able to see the received event messages in the application logs (by default under `~/.local/log/platypush/platypush.log`).
Example message trace when you copy some text on a device connected to your Pushbullet account:
```json
{
"type":"event",
"target":"hostname",
"origin":"hostname",
"id":"123abc",
"args":{
"type":"platypush.message.event.pushbullet.PushbulletEvent",
"source_user_iden":"USER_ID",
"source_device_iden":"DEVICE_ID",
"body":"Check out this link copied from my phone: https://www.google.com",
"push_type":"clip"
}
}
```
Message in case you send a Pushbullet text note to your Platypush device:
```json
{
"type":"event",
"target":"hostname",
"origin":"hostname",
"id":"123abc",
"args":{
"type":"platypush.message.event.pushbullet.PushbulletEvent",
"active":true,
"iden":"NOTIFICATION_ID",
"created":1532382991.8475788,
"modified":1532382991.851993,
"dismissed":false,
"guid":"unique client notification id",
"direction":"self",
"sender_iden":"SENDER_ID",
"sender_email":"myself@gmail.com",
"sender_email_normalized":"myself@gmail.com",
"sender_name":"My Name",
"receiver_iden":"RECEIVED_ID",
"receiver_email":"myself@gmail.com",
"receiver_email_normalized":"myself@gmail.com",
"target_device_iden":"TARGET_DEVICE_ID",
"source_device_iden":"SOURCE_DEVICE_ID",
"awake_app_guids":[
"extension-25qrgzolngx"
],
"body":"Take a look at this note!",
"push_type":"note"
}
}
```
Message in case you receive a push notification on one of your connected Android devices (in this case an Android message):
```json
{
"type":"platypush.message.event.pushbullet.PushbulletEvent",
"source_device_iden":"SOURCE_DEVICE_ID",
"source_user_iden":"SOURCE_USER_ID",
"client_version":289,
"dismissible":true,
"icon":"base64 encoded jpeg icon",
"title":"Facebook Friend sent a message",
"body":"How are your plans for tonight?",
"application_name":"Messenger",
"package_name":"com.facebook.orca",
"notification_id":"10000",
"notification_tag":"NOTIFICATION_TAG",
"conversation_iden":"{\"package_name\":\"com.facebook.orca\",\"tag\":\"NOTIFICATION_TAG\",\"id\":10000}",
"push_type":"mirror"
}
```
Message processed when you send a file to your Platypush virtual device over Pushbullet:
```json
{
"active":true,
"iden":"PUSH_ID",
"created":1532383937.424952,
"modified":1532383937.437808,
"dismissed":false,
"guid":"unique client notification id",
"direction":"self",
"sender_iden":"SENDER_ID",
"sender_email":"myself@gmail.com",
"sender_email_normalized":"myself@gmail.com",
"sender_name":"My Name",
"receiver_iden":"RECEIVED_ID",
"receiver_email":"myself@gmail.com",
"receiver_email_normalized":"myself@gmail.com",
"target_device_iden":"TARGET_DEVICE_ID",
"source_device_iden":"SOURCE_DEVICE_ID",
"file_name":"My Picture 123.jpg",
"file_type":"image/jpeg",
"file_url":"https://dl2.pushbulletusercontent.com/My-Picture-123.jpg",
"image_width":814,
"image_height":726,
"image_url":"https://lh3.googleusercontent.com/IMAGE_ID",
"push_type":"file"
}
```
Also, if you enabled notification mirroring on your Pushbullet devices, then any new push notification will be shown on the Platypush web panel and dashboard as well.
Now you can start building your rules on Pushbullet events. A full example:
```yaml
event.hook.OnPushbulletEvent:
if:
type: platypush.message.event.pushbullet.PushbulletEvent
then:
action: procedure.OnPushbulletEvent
procedure.sync.OnPushbulletEvent:
# If it's a clipboard message coming from a device with universal copy&paste enabled,
# then synchronize the text body to the system clipboard of the device where Platypush runs.
# It basically extends the universal copy&paste also to your Platypush devices even if
# they don't have the Pushbullet browser extension or app installed.
- if ${context['event'].args['push_type'] == 'clip'}:
-
action: clipboard.copy
args:
text: ${context['event'].args['body']}
# If it's a picture being sent over Pushbullet, then copy it on my USB hard drive
- if ${context['event'].args['push_type'] == 'file' and context['event'].args['file_type'].startswith('image/')}:
-
action: shell.exec
args:
cmd: "wget -O \"/mnt/hd/images/${context['event'].args['file_name']}\" \"${context['event'].args['file_url']}\""
# Back up to a local folder the text notes being sent to Platypush over Pushbullet
- if ${context['event'].args['push_type'] == 'note'}:
-
action: shell.exec
args:
cmd: "cat <<EOF > \"/home/user/notes/${context['event'].args['iden']}\"\n${context['event'].args['body']}\nEOF"
```
You can also send raw Platypush messages (requests, responses and events) over Pushbullet as raw JSON. If Platypush can interpret a Pushbullet push as a valid JSON message, then it will route it to the main application bus.
Such feature is quite useful for example to execute plugin actions or deliver events to your Platypush devices through your Android device, using [Tasker](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm) with the [Pushbullet plugin](https://play.google.com/store/apps/details?id=com.gerus.push.tasker). For instance, you can create a rule that sends a specific text to your Platypush device or a JSON request with a properly formatted request whenever your phone enters your home area, for example to turn on the lights or the heating.
You can also communicate the other way around: you can programmatically send pushes to Pushbullet from Platypush using the [plugin](https://platypush.readthedocs.io/en/latest/platypush/plugins/pushbullet.html) and you can build rules in Tasker on your mobile device to execute specific actions depending on the received message - for example start ringing if you say "find my phone" to the assistant, play a song by URI on the Spotify app, open Google Maps with the directions from your home to a specific place, and so on.
You can also connect [IFTTT](https://ifttt.com) to Platypush actions by leveraging Pushbullet. For example, you can create an applet triggered on sunset (date/time channel) to turn on the lights by sending a push like this to your Platypush device:
```json
{"type":"request", "target":"hostname", "action":"light.hue.on"}
```
# Kafka backend
[Backend reference](https://platypush.readthedocs.io/en/latest/platypush/backend/kafka.html)

@ -776,7 +776,7 @@ You can (or should) of course also use the [MQTT backend](Backends#mqtt-backend)
* Send and receive pictures
* ...and so on
Note that you need to enable the Pushbullet backend in order to use this plugin.
Note that you need to enable the [Pushbullet backend](backends#pushbullet-backend) in order to use this plugin.
Example command to send a file to all of your connected Pushbullet devices: