Added sunset reset feature
This commit is contained in:
1 parent
98a66a1e99
commit
1b637e1ff4
6 files changed
+41
-2
No files matched your search
Vendored
+1
-1
@@ -14,7 +14,7 @@ pipeline {
|
|||||||
frigate_config = readJSON file: 'frigate_config.json'
|
frigate_config = readJSON file: 'frigate_config.json'
|
||||||
}
|
}
|
||||||
|
|
||||||
ansiblePlaybook credentialsId: 'rivendell-ssh-key', disableHostKeyChecking: true, extras: "--extra-vars 'mqtt_password=\"${frigate_config.mqtt.password}\" garage_rtsp_password=\"${frigate_config.rtsp.garage.password}\" front_door_rtsp_password=\"${frigate_config.rtsp.front_door.password}\" back_door_rtsp_password=\"${frigate_config.rtsp.back_door.password}\" family_room_rtsp_password=\"${frigate_config.rtsp.family_room.password}\"'", playbook: 'install.yaml'
|
ansiblePlaybook credentialsId: 'rivendell-ssh-key', disableHostKeyChecking: true, extras: "--extra-vars 'mqtt_password=\"${frigate_config.mqtt.password}\" garage_rtsp_password=\"${frigate_config.rtsp.garage.password}\" front_door_rtsp_password=\"${frigate_config.rtsp.front_door.password}\" back_door_rtsp_password=\"${frigate_config.rtsp.back_door.password}\" family_room_rtsp_password=\"${frigate_config.rtsp.family_room.password}\" ipgeolocation_api_key=\"${frigate_config.ipgeolocation.api_key}\"'", playbook: 'install.yaml'
|
||||||
ansiblePlaybook credentialsId: 'rivendell-ssh-key', disableHostKeyChecking: true, playbook: 'stop.yaml'
|
ansiblePlaybook credentialsId: 'rivendell-ssh-key', disableHostKeyChecking: true, playbook: 'stop.yaml'
|
||||||
ansiblePlaybook credentialsId: 'rivendell-ssh-key', disableHostKeyChecking: true, playbook: 'start.yaml'
|
ansiblePlaybook credentialsId: 'rivendell-ssh-key', disableHostKeyChecking: true, playbook: 'start.yaml'
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -72,7 +72,7 @@ cameras:
|
|||||||
- 242,534,609,527,534,848,89,836 # Plants on patio
|
- 242,534,609,527,534,848,89,836 # Plants on patio
|
||||||
- 681,528,832,522,876,834,635,829 # Logs on patio
|
- 681,528,832,522,876,834,635,829 # Logs on patio
|
||||||
family_room:
|
family_room:
|
||||||
enabled: true
|
enabled: false
|
||||||
ffmpeg:
|
ffmpeg:
|
||||||
inputs:
|
inputs:
|
||||||
- path: 'rtsp://{FRIGATE_FAMILY_ROOM_RTSP_USERNAME}:{FRIGATE_FAMILY_ROOM_RTSP_PASSWORD}@192.168.0.104:554/live/ch0'
|
- path: 'rtsp://{FRIGATE_FAMILY_ROOM_RTSP_USERNAME}:{FRIGATE_FAMILY_ROOM_RTSP_PASSWORD}@192.168.0.104:554/live/ch0'
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
MQTT_USERNAME: frigate
|
MQTT_USERNAME: frigate
|
||||||
MQTT_PASSWORD: ${MQTT_PASSWORD}
|
MQTT_PASSWORD: ${MQTT_PASSWORD}
|
||||||
|
IPGEOLOCATION_API_KEY: ${IPGEOLOCATION_API_KEY}
|
||||||
volumes:
|
volumes:
|
||||||
- type: bind
|
- type: bind
|
||||||
source: /etc/localtime
|
source: /etc/localtime
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
prompt: Enter password for back door camera RTSP stream user motion
|
prompt: Enter password for back door camera RTSP stream user motion
|
||||||
- name: family_room_rtsp_password
|
- name: family_room_rtsp_password
|
||||||
prompt: Enter password for family room camera RTSP stream user frigate
|
prompt: Enter password for family room camera RTSP stream user frigate
|
||||||
|
- name: ipgeolocation_api_key
|
||||||
|
prompt: Enter API key for IPGeolocation
|
||||||
tasks:
|
tasks:
|
||||||
- name: Create Frigate config Docker volume directory
|
- name: Create Frigate config Docker volume directory
|
||||||
become: true
|
become: true
|
||||||
@@ -123,6 +125,8 @@
|
|||||||
password: '{{back_door_rtsp_password}}'
|
password: '{{back_door_rtsp_password}}'
|
||||||
family_room:
|
family_room:
|
||||||
password: '{{family_room_rtsp_password}}'
|
password: '{{family_room_rtsp_password}}'
|
||||||
|
ipgeolocation:
|
||||||
|
api_key: '{{ipgeolocation_api_key}}'
|
||||||
community.postgresql.postgresql_query:
|
community.postgresql.postgresql_query:
|
||||||
login_host: '{{homelab_config.database.host}}'
|
login_host: '{{homelab_config.database.host}}'
|
||||||
login_user: '{{homelab_config.database.user}}'
|
login_user: '{{homelab_config.database.user}}'
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
flask==2.3.2
|
flask==2.3.2
|
||||||
paho-mqtt==1.6.1
|
paho-mqtt==1.6.1
|
||||||
|
requests==2.31.0
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
|
import json
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
import requests
|
||||||
from flask import Blueprint, request, jsonify
|
from flask import Blueprint, request, jsonify
|
||||||
import paho.mqtt.publish as mqtt_publish
|
import paho.mqtt.publish as mqtt_publish
|
||||||
|
|
||||||
@@ -9,6 +12,32 @@ import paho.mqtt.publish as mqtt_publish
|
|||||||
blueprint = Blueprint('detection', __name__)
|
blueprint = Blueprint('detection', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_sunset() -> datetime:
|
||||||
|
IPGEOLOCATION_API_KEY = os.environ['IPGEOLOCATION_API_KEY']
|
||||||
|
ipgeolocation_api_response = requests.get(f'https://api.ipgeolocation.io/astronomy?apiKey={IPGEOLOCATION_API_KEY}&location=Winter+Haven,+FL')
|
||||||
|
ipgeolocation_api_response.raise_for_status()
|
||||||
|
|
||||||
|
astronomical_json = json.loads(ipgeolocation_api_response.content)
|
||||||
|
sunset_time = datetime.strptime(astronomical_json['sunset'], '%H:%M').time()
|
||||||
|
sunset_date = datetime.now().date()
|
||||||
|
if sunset_time < datetime.now().time():
|
||||||
|
# Sunset has already passed today
|
||||||
|
sunset_date += timedelta(days=1)
|
||||||
|
return datetime.combine(sunset_date, sunset_time)
|
||||||
|
|
||||||
|
|
||||||
|
def reset_all_camera_detection_at_sunset():
|
||||||
|
while True:
|
||||||
|
sunset = get_sunset()
|
||||||
|
seconds_until_sunset = (sunset - datetime.now()).total_seconds()
|
||||||
|
sleep(seconds_until_sunset)
|
||||||
|
|
||||||
|
set_camera_detection('front_door', True)
|
||||||
|
set_camera_detection('back_door', True)
|
||||||
|
set_camera_detection('garage', True)
|
||||||
|
set_camera_detection('family_room', True)
|
||||||
|
|
||||||
|
|
||||||
def set_camera_detection(camera: str, value: bool, delay: int = 0) -> None:
|
def set_camera_detection(camera: str, value: bool, delay: int = 0) -> None:
|
||||||
sleep(delay)
|
sleep(delay)
|
||||||
|
|
||||||
@@ -35,3 +64,7 @@ def camera_detect_POST(camera):
|
|||||||
return jsonify({
|
return jsonify({
|
||||||
'status': 'success'
|
'status': 'success'
|
||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
|
|
||||||
|
sunset_reset_thread = Thread(target=reset_all_camera_detection_at_sunset, args=())
|
||||||
|
sunset_reset_thread.start()
|
||||||
Reference in new issue
Block a user