class PushsaferNotificationService(BaseNotificationService): """Implement the notification service for Pushsafer.""" def __init__(self, privatekey): """Initialize the service.""" from pushsafer import Client self._privatekey = privatekey self.pushsafer = Client("", privatekey=self._privatekey) def send_message(self, message='', **kwargs): """Send a message to a user.""" # Make a copy and use empty dict if necessary data = dict(kwargs.get(ATTR_DATA) or {}) data['title'] = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) targets = kwargs.get(ATTR_TARGET) if not isinstance(targets, list): targets = [targets] for target in targets: if target is not None: data['device'] = target try: self.pushsafer.send_message(message, data['title'], "", "", "", "", "", "", "0", "", "", "") except ValueError as val_err: _LOGGER.error(str(val_err))
class PushSafer(): """ Notifier for PushSafer\n For more information visit:\n https://www.pushsafer.com/ """ def __init__(self, config: Config): self.key = config.push_safer["key"] self.device_id = config.push_safer["deviceId"] self.enabled = config.push_safer["enabled"] if self.enabled and (not self.key or not self.device_id): raise PushSaferConfigurationError() if self.enabled: self.client = Client(self.key) def send(self, item: Item) -> None: """ Sends item information to the Pushsafer endpoint. """ if self.enabled: log.debug("Sending PushSafer Notification") message = f"New Amount: {item.items_available}" self.client.send_message(message, item.display_name, self.device_id, "", "", "", "", "", "", "", "", "", "", "", "", "")
class PushsaferNotificationService(BaseNotificationService): """Implement the notification service for Pushsafer.""" def __init__(self, privatekey): """Initialize the service.""" from pushsafer import Client self._privatekey = privatekey self.pushsafer = Client( "", privatekey=self._privatekey) def send_message(self, message='', **kwargs): """Send a message to a user.""" # Make a copy and use empty dict if necessary data = dict(kwargs.get(ATTR_DATA) or {}) data['title'] = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) targets = kwargs.get(ATTR_TARGET) if not isinstance(targets, list): targets = [targets] for target in targets: if target is not None: data['device'] = target try: self.pushsafer.send_message(message, data['title'], "", "", "", "", "", "", "0", "", "", "") except ValueError as val_err: _LOGGER.error(str(val_err))
def send_push(self, message): try: init(privatekey=conf['keys']['pushsafer']) client = Client("") client.send_message(message=message, title="Found", device='a', sound="1", icon="20", vibration="2", answer=0, picture1=None, picture2=None, picture3=None, expire=None, time2live=None, url="", retry=None, urltitle=None, priority=5) print("Push notification has been send") except Exception as e: print(Fore.RED + str(e) + Fore.RESET)
class PushSafer(): def __init__(self, config: Config): self.key = config.push_safer["key"] self.device_id = config.push_safer["deviceId"] self.enabled = config.push_safer["enabled"] if self.enabled and (not self.key or not self.device_id): raise PushSaferConfigurationError() if self.enabled: self.client = Client(self.key) def send(self, item: Item): if self.enabled: log.debug("Sending PushSafer Notification") message = f"New Amount: {item.items_available}" self.client.send_message(message, item.display_name, self.device_id, "", "", "", "", "", "", "", "", "", "", "", "", "")