-
Notifications
You must be signed in to change notification settings - Fork 1k
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
base: jasper-dev
Are you sure you want to change the base?
Re-adding notification plugin functionality #416
Conversation
Signed-off-by: Edouard Poitras <edouardpoitras@gmail.com>
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>
Not sure how to get around codacy complaining about code complexity... |
Implemented from pull#416 by edouardpoitras jasperproject#416
This is my next step; to work on notifications. Do you have an example notification I could take a look at setup like this? |
@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. |
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:
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. |
Good to know. I like the two options you outlined above. I'll leave this here for reference. Feel free to close. |
yeah I had this working; now it shows the notification in the debug logs, but I hear nothing. Anything change? |
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. |
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