Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-adding notification plugin functionality #416

Open
wants to merge 2 commits into
base: jasper-dev
Choose a base branch
from

Conversation

edouardpoitras
Copy link

The notification plugins don't seem to be implemented in 2.0.
This pull request adds the functionality as a normal plugin.

Signed-off-by: Edouard Poitras edouardpoitras@gmail.com

Signed-off-by: Edouard Poitras <edouardpoitras@gmail.com>
@edouardpoitras
Copy link
Author

With this PR, you can now add a new plugin in plugins/notification/plugin_name/. You can also specify a 'notification_interval: X' in your profile.yml (X being an integer representing the number of seconds before polling for more notifications). However, each individual plugin will provide it's own timestamp representing when to next invoke it's notification routine.

Here's an example of a notification plugin that will give the user some encouragement in their daily lives:

import datetime
from client import plugin
class EncouragePlugin(plugin.NotificationPlugin):
    def check_notification(self, queue, count):
        encouragement = random.choice(["You can do it!", "Don't give up!", "You're almost there!"])
        queue.put(encouragement)
        # Encourage the user every 5 minutes
        now = datetime.datetime.now()
        next_encouragement = now + datetime.timedelta(seconds=300)
        return next_encouragement

There is another example in the PR.

Signed-off-by: Edouard Poitras <edouardpoitras@gmail.com>
@edouardpoitras
Copy link
Author

Not sure how to get around codacy complaining about code complexity...

Theb-1 added a commit to Theb-1/jasper-client that referenced this pull request Jan 10, 2016
@ghost
Copy link

ghost commented Mar 7, 2016

This is my next step; to work on notifications. Do you have an example notification I could take a look at setup like this?

@edouardpoitras
Copy link
Author

@MattCurryCom Hey Matt, you can take a look at the file plugins/notification/test/test.py in this PR for an example that simply outputs the number of times the notification method was executed. Another example is in my second comment of this thread.

@Holzhaus
Copy link
Member

Thanks for the effort. There are several problems with the way jasper currently handles notifications that i'd like to address before merging that them into the dev branch.

On the UI side, I think that we should make notifications accessible in several ways, so that the user decides what happens if a plugin generates a notification:

  1. Jasper just starts telling you stuff. This is the way the current master branch does it and that might fit well into some use cases, but it might literally give people a heart attack when jasper suddenly starts talking when you're not expecting it.
  2. Jasper could notify users that notifications are ready, e.g. by a blinking LED or just by playing a beep sound and the user then has to say "Jasper, what's up?" before jasper starts talking.

Both are valid ways to access notifications and i'd like to make both possible, but that will have some implications how notifications have to be implemented (probably by pushing the message and maybe a callback into a queue that will be checked from time to time).

Also, the current way of checking for notifications it not really optimal. I'd rather have a single process or thread (possibly running in low priority mode) that will check for notifications periodically and put them into a queue, then wait and then recheck. We currently have a bunch of bug reports that are somehow the gmail notifications are crashing jasper - probably because the notifier eats all CPU resources on the Raspberry Pi so that it eventually gets too slow to handle speech IO.

@edouardpoitras
Copy link
Author

Good to know. I like the two options you outlined above. I'll leave this here for reference. Feel free to close.

@ghost
Copy link

ghost commented Jul 8, 2016

yeah I had this working; now it shows the notification in the debug logs, but I hear nothing.
NFO:client.conversation:Nothing has been said or transcribed.
INFO:client.conversation:Received notification: 'New email from Matt Curry.'
INFO:client.conversation:Received notification: 'New email from Matt Curry.'
INFO:client.conversation:Received notification: 'New email from Matt Curry.'

Anything change?

@ghost
Copy link

ghost commented Jul 8, 2016

btw guys, I added a jasper-project slack channel, there is a locked devs-only room. Please join, I really need to pick the brains of you guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants