def _send_notification(self, warningSettings: Dict, sensorInfo: Dict, deviceInfo: Dict, timeSinceLastValue: str): if not warningSettings['enableNotificationViaPushbullet']: return if not timeSinceLastValue: self._notificationSent = False return if self._notificationSent: return token = warningSettings['pushbulletToken'] sensorName = sensorInfo['name'] sensorType = sensorInfo['type'] deviceName = deviceInfo['name'] title = 'DashboardLeaf - Outdated Value Warning' description = f'Last value for sensor "{sensorName}" received {timeSinceLastValue} ' \ f'(type: {sensorType}, device: {deviceName})' Helpers.send_notification_via_pushbullet(token, title, description) self._notificationSent = True
def _send_notification(self, remainingDays: int, nextEventDate: str): notificationSettings = self._settings['notificationViaPushbullet'] if not notificationSettings['enable']: self._lastNotificationDate = None return if remainingDays != notificationSettings['daysBeforeEvent']: self._lastNotificationDate = None return now = self._get_current_date_time() if now.hour < notificationSettings['hour']: self._lastNotificationDate = None return if self._is_already_notified(now): return self._lastNotificationDate = now.date() title = 'DashboardLeaf - Garbage Schedule Notification' description = f'"{self._settings["garbageType"]}" will be collected in {remainingDays} days ({nextEventDate})' Helpers.send_notification_via_pushbullet( notificationSettings['pushbulletToken'], title, description)