Comments (9)
Even better, I've found an alternate BusyBox that includes wc and nc. Using these I've created a script to post to a home assistant webhook. I'll document it a bit better and submit the code here.
from merkury1080p.
Here is the shell script I'm using with the included instructions you provided in Comment 2:
!#/bin/sh
#DEBUG_FILE=/mnt/mmc01/output.log
DEBUG_FILE=$1
# Define Webhook to trip
WEBHOOK="driveway_motion"
# Build the PATH to POST
POST_PATH="/api/webhook/${WEBHOOK}"
# Hostname or IP of Home Assistant
HOST=192.168.x.x
# Port Number
PORT=8123
# This can be just about anything for our purposes
BODY="Put here HTML body...."
# Get the Body Length for proper POST form data
BODY_LEN=$( echo -n "${BODY}" | /mnt/mmc01/busybox wc -c )
contains() {
string="$1"
substring="$2"
if test "${string#*$substring}" != "$string"
then
return 0 # $substring is in $string
else
return 1 # $substring is not in $string
fi
}
# contains(string, substring)
#
# Returns 0 if the specified string contains the specified substring,
# otherwise returns 1.
IFS='$\n'
echo -n "" > $DEBUG_FILE
while true; do
read -r BUF;
if [ $? -ne 0 ]; then
sleep 1;
continue
fi
if contains "$BUF" "--motion detection alarm --"; then
#echo "motion detected"
echo -ne "POST ${POST_PATH} HTTP/1.0\r\nHost: ${HOST}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ${BODY_LEN}\r\n\r\n${BODY}" | \
/mnt/mmc01/busybox nc -i 3 ${HOST} ${PORT}
fi
echo $BUF >> $DEBUG_FILE
done
I then create an automation in HA that sets an input boolean and resets it to off 30 seconds later.
This then triggers my object detection using the DOODS addon and finally sends me a telegram notification.
Turn this cheap camera into a $300 object detection beast!!!
Later this week I will fork and draw up a pull request.
from merkury1080p.
@guino unfortunately, the included wget lacks the ability to use --method. Unless I'm unaware of some wget-fu, this was the only way I could accomplish it.
from merkury1080p.
@williamkennyAK curl
-- I haven't seen any busybox with it. The busybox posted for the SD card ( https://github.com/guino/Merkury720/tree/main/mmc ) has wget
which should be able to do web requests similar to curl. This link also has relevant Home Assistant information: https://github.com/guino/BazzDoorbell/wiki/How-do-I-integrate-with-Home-Assistant,-HomeBridge,-Domoticz,-etc
from merkury1080p.
I ended up going a slightly different route. I used the ffmpeg camera integration with the ffmpeg_motion integration to trigger a motion event.
https://www.home-assistant.io/integrations/ffmpeg_motion/
from merkury1080p.
@williamkennyAK you should have been able to use the existing busybox (wget) to perform the post, but as long as it works it doesn't hurt to have more options -- can you post a zip or link of the busybox you used (that works with the script) ?
EDIT: Nevermind - the busybox we've been using has nc
so this should work as-is.
from merkury1080p.
@williamkennyAK that makes sense, I did not notice the wget in busybox was not POST capable. It's odd that homeassistant doesn't allow for 'GET' requests like domoticz, homebridge, etc -- in any case I assume you could also have used mqtt with the mosquito_pub tool provided in the link of the 2nd post above.
Like I said, always nice to have more options.
from merkury1080p.
V2:
This is a work in progress but here we go:
#!/bin/sh
# notify.sh
# [email protected]
# GitHub: williamkennyAK
#
# Parses ppsapp logs for keyword to trigger local motion notifications
# Generates motion alerts from tuya linux based cameras
# ADD LINK TO REPOS...
#
# usage:
#
# /mnt/mmc01/ppsapp | /mnt/mmc01/notify.sh <keyword> <worker> <logfile> <loglevel>
# * denotes required
# * keyword - keyword to look for in ppsapp logs
# * worker - script or binary that executes notifications
# * logdir - /full/path/to/log/dir
# * loglevel - 0: silent
# 1: motion detected only
# 2: motion detected and worker output
# 3: EVERYTHING ** use this sparingly as it can build up quickly **
# It's main use is to figure out the keyword to use
keyword=$1
worker=$2
workerlog="$3/worker.log"
log="$3/notify.log"
loglevel=$4
while true; do
read -r BUF;
case "$BUF" in
*"${keyword}"*)
case $loglevel in
"1")
echo "############# MOTION DETECTED #############" >> $log
$worker
;;
"2"|"3")
echo "############# MOTION DETECTED #############" >> $log
echo "############## WORKER LOGGED ##############" >> $log
$worker >> $workerlog
;;
esac
;;
esac
case "$loglevel" in
"3")
echo "${BUF}" >> $log
;;
esac
done
I then modify custom.sh with this line:
/mnt/mmc01/ppsapp | /mnt/mmc01/notify motion /mnt/mmc01/post.sh /mnt/mmc01/logs 2 &
With this script you could then use the mosquitto_pub method with this script giving you a bit more control.
My ppsapp denoted a motion trigger in the following way:
[13:17:26.813 INFO pps_tuya_media.c:1808]motion detected upload pic
[13:17:32.874 INFO pps_tuya_media.c:1788]motion detected but in shield time
[13:17:43.041 INFO pps_tuya_media.c:1788]motion detected but in shield time
from merkury1080p.
Submitted pull request with changes made including web interface for configuration.
from merkury1080p.
Related Issues (20)
- Weird Password Issue HOT 6
- Mini 11S / 4.0.7 - Can't install hack [User error] HOT 2
- Mini 11-S Firmware 5.2 HOT 8
- feature request: offline mode HOT 2
- Will this work on firmware version 5.2.8? HOT 16
- Rtsp stream does not start without the internet HOT 2
- Damn, I bricked my camera! HOT 20
- LSC Indoor IP Camera Firmware v7.6.32 HOT 178
- Merkury Smart Security Camera (MIC-CW020-101W) - Firmware 5.2.7 HOT 3
- Merkury 1080P (MIC-CW017-101W) - Firmware Version 4.0.7 - Patch Request HOT 30
- Cannot get Bullet 4S to work with hack HOT 9
- Merkury Mi-CW017 help HOT 3
- LSC Smart Outdoor (IP) Camera - Hack not working HOT 115
- tuya_config.json missing in LSC Smart Home Camera Mini 16S HOT 2
- Snapshot quality HOT 3
- ppsapp patch request HOT 20
- Firmware 5.2.1 OEM device MINI7S-A5MB_F37 REV 1_0 2021-06-11 HOT 20
- GNC-CW020, Firmware V4.40.5 HOT 2
- Paid Patch Request HOT 22
- Merkury MIC-CW220-101W HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from merkury1080p.