Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/prudynt-t/files/agent-adapter
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,7 @@ agent_apply_config() {
agent_persist_if_present "$source_file" motion.send2gphotos
agent_persist_if_present "$source_file" motion.send2mqtt
agent_persist_if_present "$source_file" motion.send2ntfy
agent_persist_if_present "$source_file" motion.send2pushover
agent_persist_if_present "$source_file" motion.send2storage
agent_persist_if_present "$source_file" motion.send2telegram
agent_persist_if_present "$source_file" motion.send2webhook
Expand Down
8 changes: 7 additions & 1 deletion package/prudynt-t/files/motion
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ start() {
need_photo=false
need_video=false

for service in email ftp gphotos gotify mqtt ntfy storage telegram webhook; do
for service in email ftp gphotos gotify mqtt ntfy pushover storage telegram webhook; do
if [ "true" = "$(get_value send2${service})" ]; then
[ "true" = "$(jct /etc/send2.json get ${service}.send_photo 2>/dev/null)" ] && need_photo=true
[ "true" = "$(jct /etc/send2.json get ${service}.send_video 2>/dev/null)" ] && need_video=true
Expand Down Expand Up @@ -157,6 +157,12 @@ start() {
send2_pids="$send2_pids $!"
fi

if [ "true" = "$(get_value send2pushover)" ]; then
echo_info "Send alert to Pushover"
MOTION_PHOTO_FILE="$MOTION_PHOTO_FILE" MOTION_VIDEO_FILE="$MOTION_VIDEO_FILE" send2pushover &
send2_pids="$send2_pids $!"
fi

if [ "true" = "$(get_value send2xmpp)" ]; then
echo_info "Send alert to XMPP"
if [ -n "$MOTION_PHOTO_FILE" ] && [ -f "$MOTION_PHOTO_FILE" ]; then
Expand Down
2 changes: 1 addition & 1 deletion package/thingino-raptor/files/raptor-motion
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MOTION_ALARM="${MOTION_ALARM:-/run/motion/motion_alarm}"
CHAN="${MOTION_CHANNEL:-0}"
CLIP_SECS="${MOTION_CLIP_SECS:-10}"

SERVICES="email ftp gphotos gotify mqtt ntfy storage telegram webhook"
SERVICES="email ftp gphotos gotify mqtt ntfy pushover storage telegram webhook"
MOTOR_ACTIVE_FLAG="${MOTOR_ACTIVE_FLAG:-/run/motors-active}"

motor_active() {
Expand Down
2 changes: 1 addition & 1 deletion package/thingino-send2/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ config BR2_PACKAGE_THINGINO_SEND2
select BR2_PACKAGE_THINGINO_JCT
help
Shared send-to-* notification toolkit (email, FTP, Telegram, MQTT,
ntfy, webhook, storage, Google Photos, Gotify).
ntfy, Pushover, webhook, storage, Google Photos, Gotify).

Provides /usr/sbin/send2* plus /etc/send2.json and shared helpers.
Default send2common is prudynt capture; raptor and timps install
Expand Down
11 changes: 10 additions & 1 deletion package/thingino-send2/files/send2.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"send_video": false
},
"mqtt": {
"host": "",
"host": "",
"port": 1883,
"use_ssl": false,
"tls_skip_verify": false,
Expand All @@ -73,6 +73,15 @@
"message": "{\"timestamp\": \"%s\"}",
"send_photo": false
},
"pushover": {
"token": "",
"user": "",
"title": "Thingino Camera",
"message": "Motion detected at %Y-%m-%d %H:%M:%S",
"priority": 0,
"send_photo": false,
"send_video": false
},
"speaker": {
"file": "",
"volume": 80,
Expand Down
142 changes: 142 additions & 0 deletions package/thingino-send2/files/send2pushover
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/bin/env sh
# Sends notifications to Pushover
# https://pushover.net/api
#
# NOTE (verbose mode): curl --verbose dumps the multipart request body to
# stderr, which includes token and user key in cleartext. echo_command's
# preview is redacted, but the real request is not. Pre-existing behaviour
# across the send2 toolkit (gotify token in URL, ntfy in Authorization
# header); do not enable -v in contexts where stderr is captured/displayed.

. /usr/share/prudynt-helpers
. /usr/share/send2common

domain="pushover"
config_file="/etc/send2.json"

show_help() {
echo "Usage: $0 [options]
Where:
-t token Pushover application API token
-u user Pushover user (or group) key
-n title Message title
-m message Message body (strftime format)
-z N Priority (-1 lowest, 1 high; 2 emergency not supported)
-S Send photo attachment
-V Send video attachment
-v Verbose output
" >&2
exit 0
}

read_config() {
[ -f "$config_file" ] || return

message=$(get_value message)
priority=$(get_value priority)
title=$(get_value title)
token=$(get_value token)
user=$(get_value user)
}

read_config

while getopts m:n:t:u:vz:SV flag; do
case "$flag" in
m) message=$OPTARG ;;
n) title=$OPTARG ;;
t) token=$OPTARG ;;
u) user=$OPTARG ;;
v) verbose="true" ;;
z) priority=$OPTARG ;;
S) send_photo="true" ;;
V) send_video="true" ;;
*) show_help ;;
esac
done

# use config settings only if not set from command line
if [ -z "$send_photo$send_video" ]; then
send_photo=$(get_value send_photo)
send_video=$(get_value send_video)
fi

if [ -z "$token" ]; then
echo_error "Pushover token is not set"
exit 1
fi

if [ -z "$user" ]; then
echo_error "Pushover user key is not set"
exit 1
fi

[ -z "$title" ] && title="Thingino Camera"
[ -z "$message" ] && message="Motion detected at %Y-%m-%d %H:%M:%S"
[ -z "$priority" ] && priority=0

# Pushover rejects priority 2 (emergency): retry/expire params are mandatory
# for that level and we do not send them. Clamp out-of-range or emergency
# priorities to the highest supported level.
case "$priority" in
-2 | -1 | 0 | 1) ;;
2) priority=1 ;;
*)
case "$priority" in
'' | *[!0-9]*) priority=0 ;;
*) priority=1 ;;
esac
;;
esac

message=$(date +"$message")

if [ "true" = "$verbose" ]; then
curl_verbosity="--verbose"
else
curl_verbosity="--silent"
fi

curl_common="--show-error --fail --connect-timeout 10 --max-time 30 --retry 3 --location --max-redirs 5"

# Only one attachment per request: photo or video, not both.
attachment=""
if [ "true" = "$send_photo" ] && [ "true" = "$send_video" ]; then
echo_error "Pushover supports one attachment per message; enable only photo or video"
exit 1
elif [ "true" = "$send_photo" ]; then
attachment=$(copy_photo)
elif [ "true" = "$send_video" ]; then
attachment=$(copy_video)
fi

attachment_args=""
[ -n "$attachment" ] && attachment_args="-F attachment=@$attachment"

# Pushover's API rejects attachments larger than 2.5 MB.
if [ -n "$attachment" ]; then
attachment_size=$(stat -c %s "$attachment" 2>/dev/null || echo 0)
if [ "$attachment_size" -gt 2621440 ]; then
echo_error "Pushover attachment exceeds 2.5 MB limit (${attachment_size} bytes); skipping send"
[ -n "$attachment" ] && rm -f "$attachment"
exit 1
fi
fi

if [ "true" = "$verbose" ]; then
echo_command "curl $curl_common $curl_verbosity --form-string token=*** --form-string user=*** --form-string title=\"$title\" --form-string message=\"$message\" --form-string priority=$priority $attachment_args https://api.pushover.net/1/messages.json"
fi

if ! curl $curl_common $curl_verbosity \
--form-string "token=$token" \
--form-string "user=$user" \
--form-string "title=$title" \
--form-string "message=$message" \
--form-string "priority=$priority" \
$attachment_args \
"https://api.pushover.net/1/messages.json" >/dev/null; then
echo_error "Failed to send Pushover message"
exit 1
fi

exit 0
2 changes: 1 addition & 1 deletion package/thingino-send2/thingino-send2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ define THINGINO_SEND2_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0644 $(@D)/files/send2common \
$(TARGET_DIR)/usr/share/send2common
for f in send2email send2ftp send2gphotos send2gotify send2mqtt \
send2ntfy send2storage send2telegram send2webhook; do \
send2ntfy send2pushover send2storage send2telegram send2webhook; do \
$(INSTALL) -D -m 0755 $(@D)/files/$$f \
$(TARGET_DIR)/usr/sbin/$$f ; \
done
Expand Down
43 changes: 43 additions & 0 deletions package/thingino-webui/files/www/a/tool-send2-pushover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(function () {
"use strict";

const form = $("#pushoverForm");

async function loadConfig() {
await send2Load("Pushover", (data) => {
const pushover = data.pushover || {};
$("#pushover_token").value = pushover.token || "";
$("#pushover_user").value = pushover.user || "";
$("#pushover_title").value = pushover.title || "";
$("#pushover_message").value = pushover.message || "";
$("#pushover_priority").value = String(pushover.priority ?? 0);
$("#pushover_send_photo").checked =
pushover.send_photo === true || pushover.send_photo === "true";
$("#pushover_send_video").checked =
pushover.send_video === true || pushover.send_video === "true";
});
}

if (form) {
form.addEventListener("submit", (event) =>
send2Save("Pushover", form, event, () => ({
pushover: {
token: $("#pushover_token").value.trim(),
user: $("#pushover_user").value.trim(),
title: $("#pushover_title").value.trim(),
message: $("#pushover_message").value,
priority: Number($("#pushover_priority").value) || 0,
send_photo: $("#pushover_send_photo").checked,
// Photos and videos are mutually exclusive attachments in the
// Pushover API; the UI only exposes photo, so persist false rather
// than whatever the checkbox held.
send_video: false,
enabled: true,
},
})),
);
}

send2SetupReload($("#pushover-reload"), "Pushover", loadConfig);
loadConfig();
})();
3 changes: 3 additions & 0 deletions package/thingino-webui/files/www/a/tool-send2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ftp: { photo: true, video: true },
telegram: { photo: true, video: true },
gotify: { photo: false, video: false },
pushover: { photo: true, video: false },
mqtt: { photo: true, video: false },
webhook: { photo: true, video: true },
storage: { photo: true, video: true },
Expand Down Expand Up @@ -126,6 +127,7 @@
"ftp",
"telegram",
"gotify",
"pushover",
"mqtt",
"webhook",
"storage",
Expand All @@ -149,6 +151,7 @@
"ftp",
"telegram",
"gotify",
"pushover",
"mqtt",
"webhook",
"storage",
Expand Down
Loading