pogom icon indicating copy to clipboard operation
pogom copied to clipboard

Notifications to both iOS & Android mobile via Pushbullet

Open djv2 opened this issue 8 years ago • 32 comments

  1. Sign up & install https://www.pushbullet.com/
  2. Get your API key from pushbullet. Login to their website > left side under Settings > under Access Tokens
  3. In models.py, create the pokemon list you want notifications for > mobilealert = {1,2,3,4,5,6,7,8,9} around line 126
  4. Start the map > go to config > copy paste your API key
  5. Mobile notification includes pokemon name, expiration time, and google maps link with location

djv2 avatar Aug 17 '16 03:08 djv2

Nice work, would you mind adding disappear time in the notification?

octave-ati avatar Aug 17 '16 04:08 octave-ati

What can I say? This man commits quicker than his shadow !

octave-ati avatar Aug 17 '16 04:08 octave-ati

@Faskill done lol i added expiration time on the push notification. also pushed out getting the API key in the UI (check your config)

djv2 avatar Aug 17 '16 05:08 djv2

Yeah I saw that :) One more request : would it be possible to either be notified for the same pokemons than what's set up on my webpage or to implement a separate list of pokemons I wanna receive push notifications for directly in the webapp?

Looking up pokemons id and manually imputing them in the models.py file is a bit clunky and I think that if you manage to do that your pull request might be merged into the main repo for everyone to benefit ;)

octave-ati avatar Aug 17 '16 05:08 octave-ati

Another small request : (sorry in advance for probably annoying you, I wish I was better at programming so I could do all of this myself) Can you make it that when you input the pushbutton api key in the config.html page it writes it into config.json for later use? Thanks in advance

PS : It is working very well for me, thanks a lot by the way !

octave-ati avatar Aug 17 '16 05:08 octave-ati

On another note, would it be possible to receive only one notification per unique id? I'm not complaining I just caught an eggsecutor but I've received 5 notifications for it even after catching it :p

On 17 août 2016, at 07:01, General Zod [email protected] wrote:

@Faskill done lol i added expiration time on the push notification. also pushed out getting the API key in the UI (check your config)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

octave-ati avatar Aug 17 '16 07:08 octave-ati

i keep on getting notification about the same pokemon that is scanned and has a despawntime for 15 min. it seems every 5 minutes or so. Can it be that i get only 1 notification instead of the same every 5 minutes??

dikkedeur avatar Aug 17 '16 07:08 dikkedeur

Sorry, I won't merge anything where you need to manually edit some file. Imo this whole notification thing should work like this:

  1. On the stats page choose the pokemon that you want an alert for
  2. On the same page enter your PB key
  3. Send both the PB key and the alert-list to the server (this means one server could possibly have multiple PB-keys to send to)

I'm still unsure how to unsubscribe. Maybe a link in the PB message?

Also related to #270

nborrmann avatar Aug 17 '16 08:08 nborrmann

I agree with Step 1 The way it is right now seems fine to me concerning the location of the pb key, it is just below the Gmap api key in the config page which seems like the right place for it to be. The only problem is that it doesn't save the key you enter to the config.json file so you have to input it manually every time you restart the server.

The biggest problem right now is that it sends you several notifications for the same encounter_id but I think this should be pretty easily fixable.

That being say, I would like to thank @djv2 for his work, it's functionning very well and I've caught a Snorlax as well as a 98% IV Eggsecutor when driving back from work thanks to him ;)

octave-ati avatar Aug 17 '16 10:08 octave-ati

Can you implement a way to use multiple api key? My brother and me are using my map... Restarting the server is a problem too

or is it possible to share my notification or to create a button "pushbullet"?

omlet05 avatar Aug 17 '16 14:08 omlet05

step 1 (selecting pokemon via stats page) is turning out to be more difficult than i thought. i assumed i could just tap into the existing notification but it's all in JS and not PY :(

@Faskill it should already publish to config.json, i just checked mine and it's there. maybe you had an older version?

@omlet05 pushbullet allows you to have multiple devices per account per api key. my script, by default, should send a notification to all devices on that account. if you only want it to send to 1 device and not all, that needs to be specified

djv2 avatar Aug 17 '16 14:08 djv2

@djv2 Thanks for all your work on this, I'm glad you took the suggestions from /r/ and put them in to it's own pull. Sounds like you're really close to having a final product that @nborrmann can implement. IMO, I'd prefer to have the PB key and notifications under the server config page as I don't want "anyone" adding their PB info to my own server... but I get what @nborrmann is saying since it should technically be easier...

PhDeez avatar Aug 17 '16 16:08 PhDeez

@djv2 thanks, I will git push once my server is down but I edited it myself and it's working well :) About the notifications for the same encounter_id, would it be very hard to fix? I tried to implement it myself but it just keeps crashing my server..

octave-ati avatar Aug 17 '16 17:08 octave-ati

i believe i have already fixed the encounter_id multiple notifcation problem, just need to test it

also, in terms of setting pokemon notification select in UI - i've been looking into but having a hard time getting an array from HTML/JS into Py. any thoughts?

djv2 avatar Aug 17 '16 17:08 djv2

It works like a charm. Thank you!

blogpedrocalixto avatar Aug 17 '16 18:08 blogpedrocalixto

@Faskill just pushed fix for encounter_id multiple notification problem. i tested for myself and it works, hopefully for you too

models.py lines 121, 146, 148-152

djv2 avatar Aug 17 '16 18:08 djv2

Great work! If you can set it up so that it's possible to add pokemon you want to be notified of on the server config page, that would be amazing.

In the meantime, I'm wondering how you would best suggest integrating it with the ability to see lured pokemon? https://github.com/favll/pogom/pull/184

I combined the changes from that PR in with your changes, and I'm able to receive notifications on my mobile for the pokemon I've set up, and I'm able to see lured pokemon on my map (after having to check the "view lured pokemon" box every time I open the map, as it doesn't appear to save the setting). But I'm not able to receive notifications for lured pokemon on my mobile. I'm guessing it's because they have a different ID so it's not recognizing "luredDratini" as Dratini.

Any suggestions? Thanks for all the hard work! Loving this.

adamblaine avatar Aug 17 '16 19:08 adamblaine

@adamblaine hard to help you when https://github.com/favll/pogom/pull/184 doesn't even work for me. have tried multiple times, i even posted in pull

djv2 avatar Aug 17 '16 19:08 djv2

@djv2 Yeah, I saw that. I was worried mine wasn't working at first after setting it up, but I checked it after it had been running for an hour or so and saw luredPokemon popping up. It's been consistent since then. Did you try saving the raw files from #184 and attempting it with a fresh git clone?

The fact that I have to check the box to make them visible each time I load up the map is annoying and should really function like enabling the view Pokemon or Gyms options... but being able to finally see the lured pokemon is well worth it. And receiving notifications when a rare one pops up would be amazing. Let me know if there's anything I can do to help.

adamblaine avatar Aug 17 '16 20:08 adamblaine

Couldn't notifications settings write to the config.json? Any reason why they shouldn't?

acoreyj avatar Aug 17 '16 20:08 acoreyj

@adamblaine yea dunno, i triple checked everything i copied/pasted, no go :(

@acoreyj it should by default...at least mine is. make sure you have the latest branch (the first one i posted last night didn't work)

djv2 avatar Aug 17 '16 20:08 djv2

@djv2 Sorry I meant the actual pokemon you have checked notifications for but I realize that its meant for multiple users that may have different notification preferences.

I think to do this to work in this case the pushbullet stuff needs to be done client side instead of server side.

acoreyj avatar Aug 17 '16 20:08 acoreyj

@djv2 okay I might have somewhere to start. If you still have a version with the luredpokemon in it, fire it up. And then don't view it from your PC, access the map from your mobile device, ensure that lured Pokemon check box is enabled, and then see if some pop up. Just dialed into my home PC and the lured Pokemon aren't showing up at all there, even though the check box is enabled. On my phone, though, they all show up without issue.

adamblaine avatar Aug 17 '16 21:08 adamblaine

@djv2 when the same pokemon spawns on the same spot as before, it seems there's no notification going out. i.e. a pikachu spawns, an hour later another one spawns on the same spot, only getting the first notification

donkiel avatar Aug 18 '16 00:08 donkiel

@adamblaine tried mobile, still doesn't show lure

@donkiel i am unable to reproduce your problem. also as i think about it, there's no place in the code that even checks the location, everything is based on encounter_id (unless you tell me encounter_id is the same for same spot spawn)

djv2 avatar Aug 18 '16 02:08 djv2

the latest change makes that i dont get notifications anymore or at least not very often since i have the appropiate lists in the models.py. in short.. the spamming stopped, but a little bit too much i think. i have no idea how this is happening, but i reverted back last commit on my repo and i do get notifications again.. i know more on the same spot ( seems every 5 minutes ) but as @donkiel is mentioning i think i have/had the same problem

dikkedeur avatar Aug 18 '16 12:08 dikkedeur

I was thinking about the problem of the same Pokémon in the same place and maybe instead of implementing the changes directly to runserver.py this should be modular like the telegram implementation and have it read the database and send notifications via PB that way...

PhDeez avatar Aug 18 '16 17:08 PhDeez

I think the latest update removing the multiple notifications slows down the process somehow, so I had to revert the commit.

Without it I was receiving notifications 9-15 mins before expiry time (my scan duration is 5.5 mins), after pushing the commit I had a much shorter window between 4-10 minutes and I missed a dragonite :(

Maybe comparing the encounter_id to all the encounter ids of my large database slows down the process, would it be possible to maybe filter the pokemon_id to reduce the number of fields that need to be analyzed?

octave-ati avatar Aug 20 '16 13:08 octave-ati

How do i install this commit? sorry i am new to git. i tried typing manually to all the files with all the changes... but ended unable to run python.

is there a right way for me to install this commit without doing it all manually?

mervinpoh avatar Aug 20 '16 17:08 mervinpoh

Don't know exactly what's going on with this notification system, I've tried to add it here https://github.com/DPr00f/pogom/tree/notifications Also added a way to add the pokemons to notify directly from the config. But with no luck, I didn't get any notifications. :/ Will investigate later

DPr00f avatar Aug 22 '16 09:08 DPr00f