Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

PushBullet plugin (Pako)

Questions and comments specific to a particular plugin should go here.
bengalih
Posts: 48
Joined: Sat Feb 25, 2012 1:13 am

Re: PushBullet plugin (Pako)

Post by bengalih »

Some more info on the whole SMS handling:

Some more info on this:
https://plus.google.com/110170333398787 ... JtXGauyhsJ
https://blog.pushbullet.com/2014/06/19/ ... -computer/
https://blog.pushbullet.com/2015/07/15/ ... -computer/

Honestly, I don't totally understand how they are doing this yet.
If I set the "sync sms with my computer" option in PB, then all my native phone texts DO get synced with the PB computer app and I can send and receive them all from my computer.

However, the only event I seem to receive (using EG plugin to monitor the websocket message is):

PushBullet: WebSocket message: {u'push': {u'source_device_iden': u'XXXXXXXXXXXXX', u'type': u'sms_changed'}, u'type': u'push', u'targets': [u'stream']}

Put, the PB computer app sees the text that I received, and allows me to reply. It must be doing this out of band somehow - the first link I sent you might provide some more insight, but I don't think they have really give enough information.

Personally, I use hangouts and everyone uses my GV number, so the standard mirrors are great for me.
My wife however uses the native Verizon messaging app, so the best I can do for her right now is just to pop up a generic alert that an sms arrived - without any backing information.

UPDATE:

I was able to get it to work using the following:

curl --header 'Access-Token: XXXXXXXXXXXXXXXXXXXXXXX' "https://api.pushbullet.com/v2/permanent ... Xx_threads"

as per the googleplus link I send above.
However I'm still not sure how to tell what thread has changed or the syntax in general.

I suppose what needs to happen is that when we get an sms_changed the handler needs to work like your getPhonebook:

Code: Select all

          
                'GET',
                API + 'permanents/' + sms_devs[dev] +  '_threads')
And then parse that for the appropriate thread.id to grab the actual data.

It's a little beyond me right now, perhaps you can make quicker sense of it...

UPDATE:

Ok....I figured it out...at least I think to get the most common functionality.
It seems that the latest message will always be the first of the retrieved threads.
So, I've added code to my sms_changed handler to query the threads as soon as the sms_changed comes in.
This way we grab the latest message as the "changed event" and parse that out to present the actual SMS data.
No need to dismiss these messages either because we only get the latest, but I suppose it could be done.
It seems the dismissal for these notificaitons is not the same as for a mirror, so I'm not quite sure how to do it yet.

Attached script update will work to handle these sms messages.
Attachments
__init__.py
__init__.py with dismissal, sms_changed, and sms retrieval.
(191.3 KiB) Downloaded 129 times
bengalih
Posts: 48
Joined: Sat Feb 25, 2012 1:13 am

Re: PushBullet plugin (Pako)

Post by bengalih »

One last update until I hear back from you (as it is all working well enough for me now).

Had issues when I enabled encryption, so added encryption back to the sms_changed request for threads.
Interestingly, it turns out the "dismissal" types back to the device should NOT be encrypted. The device apparently doesn't do anything with an encrypted dismissal packet, but even with end-to-end encryption setup, it happily process a non encrypted dismissal.

Also need to make a change - for some reason the notification_tag was in the packet from a "test notification" (from within PB app), but was not present when encrypted, so I had to fix the logic there.

Now, all my tests are working with encryption and without.
Tests:

Incoming Call (standard mirror)
Test notification (standard mirror + dismissal)
Hangout message (standard mirror + dismissal)
SMS message (sms_changed + thread retrieval for message text. No dismissal as it isn't necessary to deal with message history issues (plus I don't know the API commands/syntax to dismiss an sms thread as it is not a mirror).

Let me know if you have any questions about what I've done...though most of it is cannibalization of your code so I think you'll easily see the changes with a diff.
Attachments
__init__.py
sms encryption fixed
(192.08 KiB) Downloaded 158 times
bengalih
Posts: 48
Joined: Sat Feb 25, 2012 1:13 am

Re: PushBullet plugin (Pako)

Post by bengalih »

Pako,

I have some more general issues with the plugin I wanted to share.

It appears there may be a memory leak. I tried this with version 2.7 and with no encryption being used (your copy, none of my modifications).
I simply add the plugin to an EMPTY tree and turn OFF mirror notification.

This is my observation.

After initial load the EG memory usage was around 37,280k after letting it sit for a couple minutes.
I came back about 10 minute later and it was at 38,132k.
Again, this was just sitting there...not receiving anything.
I then sent test notifications for about 1 minute of (the in-app test). I'm not sure how many, I just kept pressing it as much as I could for about a minute...so let's say 100 test notifications.
The memory grew to 42,160k.
I then let it sit for another 15-20 minutes and memory increased to 44,072.

So we had about 3-4MB of increase memory just for sitting for about 30-45 minutes with another 4MB of utilization just over the minute of notifications I sent.
It would appear that this pattern does not let up, and that the usage continues to increase.

I've been seeing me EG consume hundreds of MB over the past week. My new PortCheck plugin may be responsible for some of it...though it seems it stabilizes after a few minutes, I need to do more testing.
For instance I am calling OSD with my macro and I notice that OSD in itself has a memory leak that isn't pretty:
viewtopic.php?f=4&t=7433

Also, this is minor and unrelated, but the plugin gives the following on every initialization:

Code: Select all

C:\Program Files (x86)\EventGhost\lib26\site-packages\websocket\_core.py:843: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  message = getattr(e, 'strerror', getattr(e, 'message', ''))
Thanks!
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako »

Wow, that's too many topics on which I have to react.
I'm going to react to everything, but gradually.
First, I chose the following two things:
bengalih wrote:Also, can you please clarify for me use case of:
"The title of the push to use as:" eventSuffix vs. payload[0]

In my use cases I'm not seeing what this modifies or how it could be useful.
Suffix-Payload_Comparison.png
Picture above shows 6 different cases:
1) Title not missing and it is used as a suffix
2) Title not missing and it is used as the payload[0]
In the following cases, the title is missing:
3) The option "If title of push (type Note) is missing, use the first word out of the body as the event suffix" is OFF, replacement title "Note" is used as a suffix
4) The option "If title of push (type Note) is missing, use the first word out of the body as the event suffix" is OFF, replacement title "Note" is used as the payload[0]
5) The option "If title of push (type Note) is missing, use the first word out of the body as the event suffix" is ON, a replacement title is used as a suffix
6) The option "If title of push (type Note) is missing, use the first word out of the body as the event suffix" is ON, a replacement title is used as the payload[0]

Which of the options (event suffix or payload[0]) is meaningless to you?
bengalih wrote:Also, this is minor and unrelated, but the plugin gives the following on every initialization:

Code: Select all

C:\Program Files (x86)\EventGhost\lib26\site-packages\websocket\_core.py:843: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  message = getattr(e, 'strerror', getattr(e, 'message', ''))
I know about it.
BTW - this phenomenon occurs in my case during the unload plugin, not during initialization.
I maybe wrong, but I think that it would be necessary to make an adjustment websocket library to suppress this message. I think it would not be appropriate.

Pako
You know flattr ? You can Image
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako »

bengalih wrote:I have gone ahead and added a new action to the plugin "Dismiss event."
I (previously) worked on implementation of support "dismissal feature" (both active and passive).
This can be seen in this code snippet:

Code: Select all

            elif push['type'] == 'dismissal':
                pass # ToDo ####################################################
When I saw that you have interest in this feature, I decided that I finish it as soon as possible.
Version 0.2.9 it already contains.

Pako
You know flattr ? You can Image
cparker15
Posts: 5
Joined: Thu Sep 03, 2015 11:40 pm

Re: PushBullet plugin (Pako)

Post by cparker15 »

I'm using a combination of the EventGhost display for Growl for Windows and the PushBullet plugin to redirect all Growl notifications to PushBullet as Mirror type pushes. So far, it's working well, however I'm experiencing an issue with the PushBullet plugin that becomes visible when using this combination...

The EventGhost event that's triggered when Growl sends a notification to its EventGhost display is Main.Growl.EventGhost.[notification type]. This means the event prefix for all Growl-based events using the EventGhost display for Growl is "Main".

The Pushbullet plugin uses the EventGhost event prefix, if the plugin action is being called from an event, as the Pushbullet application name...

Code: Select all

payload[u'application_name'] = eg.event.prefix if \
	eg.event else 'EventGhost'
So, when I see my Growl notifications mirrored via Pushbullet, they show up as coming from the "Main" app, meaning the title of the push is prepended with the string "Main: " and I get an option to "Mute Main" on the mirror notification.

Could this please be changed so that a custom application_name can be specified via the PushBullet Mirror action?

Thank you for all of your work! Your plugins have been indispensible to me.
cparker15
Posts: 5
Joined: Thu Sep 03, 2015 11:40 pm

Re: PushBullet plugin (Pako)

Post by cparker15 »

Also, I'm trying to get this icon to show up with Mirror type pushes.
Growl 96x96 Icon
Growl 96x96 Icon
Growl_96x96.png (11.42 KiB) Viewed 4524 times
I see the icon in the EventGhost Pushbullet plugin's built-in mirror notification that can be enabled/disabled from the EventGhost plugin configuration window.

However, in the Pushbullet Windows application and the Pushbullet Chrome extension, I see empty space where the icon should be, next to the push title.

Any idea why? Is there something wrong with the icon file, itself?
bengalih
Posts: 48
Joined: Sat Feb 25, 2012 1:13 am

Re: PushBullet plugin (Pako)

Post by bengalih »

Thanks for the explanation on eventSuffix vs. payload[0] Pako.

Honestly, I was only testing incoming calls and with those I saw no difference in the messages with either option.
Your examples use Note, and I can see the difference there, but apparently this had no impact for my use case.

For now, I am going to continue to run with my version since I've implemented the SMS functionality which I need.
If you decide to integrate that feature officially I will certainly download your latest and test it out.

Since I found this plugin (and PB in general) I have looked at a couple of other solutions out there that provide notifications to XBMC. For instance Yaste for android (XBMC remote) has a plugin which will send notifications.
However, compared to how I have got them working providing the full text of the messages, and the delay I am able to implement to read longer messages, this combination is still I think the most powerful for getting your phone notifications to XBMC.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako »

cparker15 wrote:So, when I see my Growl notifications mirrored via Pushbullet, they show up as coming from the "Main" app, meaning the title of the push is prepended with the string "Main: " and I get an option to "Mute Main" on the mirror notification.

Could this please be changed so that a custom application_name can be specified via the PushBullet Mirror action?
Unfortunately, I did not understand your problem (my English is weak).
Can you explain it in other words?
Probably would help an image attached to it.
cparker15 wrote:However, in the Pushbullet Windows application and the Pushbullet Chrome extension, I see empty space where the icon should be, next to the push title.
I tried it now and it's true. Previously it worked, something probably been changed.
I'll try to make some adjustments to make it work again.

Pako
You know flattr ? You can Image
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako »

bengalih wrote:For now, I am going to continue to run with my version since I've implemented the SMS functionality which I need.
If you decide to integrate that feature officially I will certainly download your latest and test it out.
I understand.
I wrote that I will respond to your posts gradually.
But I've got no confirmation from you, that my implementation of dismissal feature is convenient for you.

The problem with SMS, we will deal with later. It will be difficult for me because I never met with "sms_changed" event (I use Textra and I in no way want to use Hangouts on my cell phone).
"sms_changed" event, this is the only reason why you can not use the official version of the plugin?

Pako
You know flattr ? You can Image
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako »

cparker15 wrote:However, in the Pushbullet Windows application and the Pushbullet Chrome extension, I see empty space where the icon should be, next to the push title.
You can download the new version 0.2.11.
Bug is fixed.

Pako
You know flattr ? You can Image
bengalih
Posts: 48
Joined: Sat Feb 25, 2012 1:13 am

Re: PushBullet plugin (Pako)

Post by bengalih »

Pako wrote:
bengalih wrote:For now, I am going to continue to run with my version since I've implemented the SMS functionality which I need.
If you decide to integrate that feature officially I will certainly download your latest and test it out.
I understand.
I wrote that I will respond to your posts gradually.
But I've got no confirmation from you, that my implementation of dismissal feature is convenient for you.

The problem with SMS, we will deal with later. It will be difficult for me because I never met with "sms_changed" event (I use Textra and I in no way want to use Hangouts on my cell phone).
"sms_changed" event, this is the only reason why you can not use the official version of the plugin?

Pako
Pako -

Yes I understand you are taking your time - I'm not rushing you since I have things mostly working as I need. Just letting you know where I am app and giving any assistance I can.
To assist I went ahead and downloaded the latest copy and it is totally broken for me.
When the plugin starts I get the following:

PushBullet: Devices received: [{u'iden': XXXXXXXXXXXXXX', u'icon': u'phone', u'created': 1443735428.0476429, u'generated_nickname': True, u'nickname': u'HTC One M8', u'modified': 1444182021.619482, u'push_token': XXXXXXXXXXXXXXXXXX', u'fingerprint': u'{"android_id":"XXXXXXXXXXX"}', u'active': True, u'model': u'HTC6525LVW', u'pushable': True, u'type': u'android', u'kind': u'android', u'manufacturer': u'HTC'}, {u'iden': XXXXXXXXXXX', u'icon': u'system', u'created': 1442880057.7031491, u'nickname': u'EG-BTMOBILE', u'modified': 1442880057.7031529, u'active': True, u'model': u'plugin by Pako', u'app_version': 24, u'type': u'stream', u'kind': u'stream', u'pushable': True, u'manufacturer': u'EventGhost'}, {u'iden': XXXXXXXXXXXXX', u'icon': u'desktop', u'created': 1442879016.13519, u'nickname': u'BTMOBILE', u'modified': 1442879016.135196, u'fingerprint': u'{"cpu":"Intel64 Family 6 Model 42 Stepping 7, GenuineIntel","computer_name":"BTMOBILE"}', u'active': True, u'model': u'Windows 7 Enterprise', u'app_version': 370, u'type': u'windows', u'kind': u'windows', u'pushable': True, u'manufacturer': u'Microsoft'}]
PushBullet: Friends received: []
PushBullet: Channels received: []
PushBullet: Targets derived: [(u'HTC One M8', XXXXXXXXXXXX', 'pc'), (u'EG-BTMOBILE', XXXXXXXXXXXXXXXX', 'pc'), (u'BTMOBILE', XXXXXXXXXX', 'pc')]
PushBullet: Email address obtained
PushBullet: Adding push messaging listener
PushBullet: WebSocket error: [Errno 1] _ssl.c:480: error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm
ERROR:root:'WebSocketClient' object has no attribute 'stopWatchdog'
PushBullet.WebSocketClosed

Based on the errors I thought it could be encryption, so I went ahead and disabled encryption and it still gives the error on start. Since it appears to close the WebSocket, I don't even see the packets come into EG, let alone be acted upon.

One strange thing to not however is that if you look in "Devices Received" you will see 3:
HTC M8 - my phone
EG-BTMOBILE - my EG instance
BTMOBILE - My computer

Thing is - there is no pushbullet running on my BTMOBILE right now - except for the EG instance. When I look at my devices on the PB website, it does not list there.
It is almost like somehow this device is being cached, but I know EG is just getting this info from the packet it receives - but I don't know how its getting that packet.
The instance I *did* have on my PC still probably has encryption enabled, and perhaps that's what is messing with the whole thing? But again I can't see how that should have any impact since it isn't running.

UPDATE: I went ahead and reloaded PushBullet on my PC and disabled encryption, still the errors above. I then shut it down and deleted the device from the webpage and now EG is only showing the two proper devices, but the error is the same.

So - in short - your copy is totally broken for me.

Regarding SMS_Changed -

This does NOT have to do with Hangouts. Hangouts provides standard mirror notifications. The only problem I had with Hangouts (from my posts the other week) was that it would send all queued notifications, so you would see the older text messages from the recipient on each new notification. This is why the dismiss function is needed, so that when the notification comes in we can dismiss it and on next text we only see the latest.

SMS_Changed is what happens when any standard SMS client gets messages. I did a quick look and it appears Textra has PushBullet support. But, most SMS clients don't - including almost every one I've seen that is stock on a phone.
My wife (for whatever reason) happens to like her stock messaging app.

So, in order for you to create the SMS_Changed events for testing you don't need to install hangouts, you just need to temporarily disable textra and use your stock message app.

To answer your question regarding my use... yes if dismissals and sms_changed were working that is my use scenario for now and I would revert back to your copies if those were running.

That being said, I am still experiencing hangs of EG. During these hangs most of my remote functionality (macros) seem to work - but not all. EG won't maximize from the system tray, so I can't see what is going on.
I have set EG to use maximum 50GB when minimized, and this initially seemed to deal with the memory leak issues I addressed previously. However something is messing up EG that wasn't before.
I recently upgraded from XBMC to Kodi and also installed a Roku, as such - I did some minor changes in my event tree and also implemented 3 new plugins:

1) Roku
2) My PortCheck plugin.
3) PushBullet

These were all done within a few days and at this point I can't say what is causing the issue. I expect that it is either my PortCheck of the PushBullet.
I am waiting to get a better pattern of when the error occurs and then start eliminating variables.

Unfortunately, it appears there is no way to have EG log to a file, and if I can't maximize EG from the system tray, then I can't see what it is doing :/

UPDATE:
def start(self):
#self.run_forever(sslopt = {"cert_reqs": CERT_NONE})
self.run_forever()

Seems the issue was above. I believe the above commented line tells it to disable SSL cert checking. When I flipped the comment to turn that back on your copy works.
I'm not sure why you disabled it, but that was the issue for me.

With that set to disable checking, the dismiss option appeared to work for me both for a test notification and for an incoming hangouts mirror notification.
Last edited by bengalih on Thu Oct 08, 2015 3:52 pm, edited 1 time in total.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: PushBullet plugin (Pako)

Post by kgschlosser »

The sms feature was working until a couple of months ago. then PushBullet did an upgrade and broke the API. I did find a solution to the problem. i would have to go back and dig through my code still has the fix for it. I think where i got stuck with it was it was listing all of the texts again like you said.so i gave up on it.

K
If you like the work I have been doing then feel free to Image
bengalih
Posts: 48
Joined: Sat Feb 25, 2012 1:13 am

Re: PushBullet plugin (Pako)

Post by bengalih »

kgschlosser wrote:The sms feature was working until a couple of months ago. then PushBullet did an upgrade and broke the API. I did find a solution to the problem. i would have to go back and dig through my code still has the fix for it. I think where i got stuck with it was it was listing all of the texts again like you said.so i gave up on it.

K
Well the issue is that an sms_changed event is sent and the plugin has no code to deal with an sms_changed event.
My modifications above added that code, so there already IS a solution to the problem. Whether my code is the cleanest, or deals with all scenarios, probably not, which is why it would probably be best if Pako reviewed it before integrating it to his code.

As I wrote in prior posts, there was not officially published API, but I did link a G+ post from PB which had some simple examples on calling sms_changed threads. Using those I was able to build the code as it is.

All I can say is it works for me tested on mine and my wife's phone when getting texts. It simply retrieves the latest thread from the sms_changed which would always appear to be the last sms "event" that caused the change.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako »

bengalih wrote:UPDATE:
def start(self):
#self.run_forever(sslopt = {"cert_reqs": CERT_NONE})
self.run_forever()

Seems the issue was above. I believe the above commented line tells it to disable SSL cert checking. When I flipped the comment to turn that back on your copy works.
Pako wrote:Warning:
Plugin version 0.2.9 (or higher) requires a new version EventGhost (r1706 or higher).
You used the latest version EventGhost ?
bengalih wrote:Unfortunately, it appears there is no way to have EG log to a file, and if I can't maximize EG from the system tray, then I can't see what it is doing :/
Log redirector and filter

Pako
You know flattr ? You can Image
Post Reply