Added webcontrol API

This commit is contained in:
ashish committed 2023-05-21 19:37:08 -04:00
1 parent a13f099e14
commit f4dcad7f00
11 files changed
+154 -15

No files matched your search

+1 -1
View File
@@ -6,6 +6,6 @@ ENTRYPOINT ["python3", "mqtt.py"]
RUN pip3 install --upgrade pip
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN pip3 install -r requirements.txt
COPY src .
+2 -2
View File
@@ -24,12 +24,12 @@ def on_message(client, userdata, message):
def subscribe():
client = mqtt.Client('frigate_notifications')
client = mqtt.Client()
client.username_pw_set(os.environ['MQTT_USERNAME'], password=os.environ['MQTT_PASSWORD'])
client.on_connect = on_connect
client.on_message = on_message
client.connect(host='192.168.0.6', port=1883)
client.connect(host='mqtt', port=1883)
client.loop_forever()
+19 -6
View File
@@ -1,7 +1,7 @@
import json
import requests
from datetime import datetime, timedelta
import requests
last_notification_time = {}
@@ -30,8 +30,15 @@ def send_notification(event_id, camera, object_label, score, priority=3):
{
'action': 'http',
'label': 'Disable (30m)',
'url': 'https://www.google.com/',
'method': 'GET',
'url': f'https://frigate.homelab.net/webcontrol/camera/{camera}/detect',
'method': 'POST',
'headers': {
'Content-Type': 'application/json'
},
'body': json.dumps({
'value': False,
'duration': 30
}),
'clear': True
}
]
@@ -49,9 +56,15 @@ def send_notification(event_id, camera, object_label, score, priority=3):
{
'action': 'http',
'label': 'DBL (30m)',
'url': 'https://www.google.com/',
'method': 'GET',
'clear': True
'url': f'https://frigate.homelab.net/webcontrol/camera/{camera}/detect',
'method': 'POST',
'headers': {
'Content-Type': 'application/json'
},
'body': json.dumps({
'value': False,
'duration': 30
})
}
]
})