Skip to content

Instantly share code, notes, and snippets.

@blacklight
Created October 30, 2020 22:28
Show Gist options
  • Save blacklight/585ee33114171b80d61a53f626977640 to your computer and use it in GitHub Desktop.
Save blacklight/585ee33114171b80d61a53f626977640 to your computer and use it in GitHub Desktop.
Script illustrating two hooks that send a notification to the configured mobile devices when a baby cry start/stop event is detected
from platypush.context import get_plugin
from platypush.event.hook import hook
from platypush.message.event.custom import CustomEvent
@hook(CustomEvent, subtype='baby-cry', state='positive')
def on_baby_cry_start(event, **_):
pb = get_plugin('pushbullet')
pb.send_note(title='Baby cry status', body='The baby is crying!')
@hook(CustomEvent, subtype='baby-cry', state='negative')
def on_baby_cry_stop(event, **_):
pb = get_plugin('pushbullet')
pb.send_note(title='Baby cry status', body='The baby stopped crying - good job!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment