Add basic notification implementation

This commit is contained in:
Nicolas Mowen 2024-07-10 12:01:37 -06:00
parent daa3d5b2c4
commit 999d676e0a
2 changed files with 49 additions and 1 deletions

View File

@ -37,3 +37,5 @@ chromadb == 0.5.0
google-generativeai == 0.6.* google-generativeai == 0.6.*
ollama == 0.2.* ollama == 0.2.*
openai == 1.30.* openai == 1.30.*
# Notifications
firebase_admin == 6.5.0

46
frigate/comms/firebase.py Normal file
View File

@ -0,0 +1,46 @@
import logging
from typing import Any, Callable
import firebase_admin
from firebase_admin import messaging
from frigate.comms.dispatcher import Communicator
from frigate.config import FrigateConfig
logger = logging.getLogger(__name__)
class FirebaseClient(Communicator): # type: ignore[misc]
"""Frigate wrapper for firebase client."""
def __init__(self, config: FrigateConfig) -> None:
firebase_admin.initialize_app(
options={
"apiKey": "AIzaSyCoweRLtvai8iNwhsoT-GH_CH_0pckqMmA",
"authDomain": "frigate-ed674.firebaseapp.com",
"projectId": "frigate-ed674",
"storageBucket": "frigate-ed674.appspot.com",
"messagingSenderId": "76314288339",
"appId": "1:76314288339:web:090e170610d3bf0966f426",
"measurementId": "G-GZ1JKNDJZK",
}
)
def subscribe(self, receiver: Callable) -> None:
"""Wrapper for allowing dispatcher to subscribe."""
pass
def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
"""Wrapper for publishing when client is in valid state."""
if topic == "review":
message = messaging.MulticastMessage(
notification=messaging.Notification(
title="Something happened",
body="There is a body",
),
tokens=[],
)
messaging.send_multicast(message)
def stop(self) -> None:
pass