Add ntfy option
This commit is contained in:
parent
444e92edce
commit
07e719bd5f
4 changed files with 35 additions and 2 deletions
|
@ -6,3 +6,6 @@ handle_ufw: false
|
|||
localnetworks:
|
||||
- 192.168.1.0/24
|
||||
- 192.168.2.0/24
|
||||
motion_bot_ntfy_server: 'http://ntfy.sh' # Empty to skip ntfy option
|
||||
motion_bot_ntfy_username: motion_bot
|
||||
motion_bot_ntfy_password: "{{ vault_motion_bot_ntfy_pass }}"
|
||||
|
|
|
@ -174,6 +174,21 @@ do
|
|||
move_to_port="${1}"
|
||||
shift
|
||||
;;
|
||||
"--ntfy-server")
|
||||
shift
|
||||
ntfy_server="${1}"
|
||||
shift
|
||||
;;
|
||||
"--ntfy-user")
|
||||
shift
|
||||
ntfy_user="${1}"
|
||||
shift
|
||||
;;
|
||||
"--ntfy-password-file")
|
||||
shift
|
||||
ntfy_password_file="${1}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
@ -200,6 +215,12 @@ if [ "${mail_alert}" == "true" ]; then
|
|||
echo "${data}" | jq '.' | mail -s "Motion event '${event_type}' on host '${motion_host}' camera '${camera_name}'" "${email_destination}"
|
||||
fi
|
||||
|
||||
if [ -n "${ntfy_server}" ]; then
|
||||
ntfy_password="$(cat "${ntfy_password_file}")"
|
||||
ntfy_data="${data}, \"topic\": \"motion_detection\""
|
||||
curl -s "${ntfy_server}" -d "${ntfy_data}"
|
||||
fi
|
||||
|
||||
message "Sending Home Assistant event ..."
|
||||
result=$(curl -s -X POST -H "Authorization: Bearer ${ha_token}" -H "Content-Type: application/json" "${ha_url}/api/events/motion_event" -d "${data}")
|
||||
return_code=$?
|
||||
|
|
|
@ -204,3 +204,12 @@
|
|||
compress
|
||||
}
|
||||
create: true
|
||||
|
||||
- name: Ensure motion_bot password file exists
|
||||
copy:
|
||||
path: motion_bot_ntfy_password_file
|
||||
content: "{{ motion_bot_ntfy_password }}"
|
||||
mode: 0600
|
||||
owner: motion
|
||||
group: motion
|
||||
when: motion_bot_ntfy_server != ''
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
hass_token='{{ vault_haos_api_calls_token }}'
|
||||
hass_uri='http://192.168.1.248:8123'
|
||||
hass_uri='{{ home_assistant_server_uri }}'
|
||||
motion_config='/etc/motion/motion.conf'
|
||||
# debug_level='DEBUG'
|
||||
on_movie_end="/usr/local/bin/process_motion_event.sh --move-to /srv/expendable_data/motion 192.168.1.251:/srv/expendable_data/ --move-to-port 1122 --remove-picture --email-destination '{{ recipient }}' --home-assistant-url http://192.168.1.248:8123 --home-assistant-token '{{ vault_haos_api_calls_token }}' --signal-destination '+358401871182' -e 'on_movie_end' -t '%t' -w '%w' -J '%J' -i '%i' -C '%C' -o '%o' -c '%$' -v '%v' -D '%D' -h '%h' -K '%K' -L '%L' -f '%f' -Q '%Q' -F '%fps' -q '%q' -N '%N' -n '%n' -h '%host'"
|
||||
on_movie_end="/usr/local/bin/process_motion_event.sh --ntfy-server '{{ motion_bot_ntfy_server }}' --ntfy-user '{{ motion_bot_ntfy_username }}' --ntfy-password-file '{{ motion_bot_ntfy_password_file }}' --move-to /srv/expendable_data/motion 192.168.1.251:/srv/expendable_data/ --move-to-port 1122 --remove-picture --email-destination '{{ recipient }}' --home-assistant-url http://192.168.1.248:8123 --home-assistant-token '{{ vault_haos_api_calls_token }}' --signal-destination '+358401871182' -e 'on_movie_end' -t '%t' -w '%w' -J '%J' -i '%i' -C '%C' -o '%o' -c '%$' -v '%v' -D '%D' -h '%h' -K '%K' -L '%L' -f '%f' -Q '%Q' -F '%fps' -q '%q' -N '%N' -n '%n' -h '%host'"
|
||||
|
|
Loading…
Reference in a new issue