Home Assistant Unofficial Reference 2024.12.1
api.py
Go to the documentation of this file.
1 """Pushbullet Notification provider."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from pushbullet import Listener, PushBullet
8 
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers.dispatcher import dispatcher_send
11 
12 from .const import DATA_UPDATED
13 
14 
15 class PushBulletNotificationProvider(Listener): # type: ignore[misc]
16  """Provider for an account, leading to one or more sensors."""
17 
18  def __init__(self, hass: HomeAssistant, pushbullet: PushBullet) -> None:
19  """Start to retrieve pushes from the given Pushbullet instance."""
20  self.hasshass = hass
21  self.pushbulletpushbullet = pushbullet
22  self.datadata: dict[str, Any] = {}
23  super().__init__(account=pushbullet, on_push=self.update_dataupdate_data)
24  self.daemondaemon = True
25 
26  def update_data(self, data: dict[str, Any]) -> None:
27  """Update the current data.
28 
29  Currently only monitors pushes but might be extended to monitor
30  different kinds of Pushbullet events.
31  """
32  if data["type"] == "push":
33  self.datadata = data["push"]
34  dispatcher_send(self.hasshass, DATA_UPDATED)
None __init__(self, HomeAssistant hass, PushBullet pushbullet)
Definition: api.py:18
None dispatcher_send(HomeAssistant hass, str signal, *Any args)
Definition: dispatcher.py:137