forked from EliasKotlyar/Xiaomi-Dafang-Hacks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix motion detection userscripts (EliasKotlyar#500)
* Correct detection scripts so they can run multiple scripts * Add some documentation around motion detection scripts
- Loading branch information
Showing
4 changed files
with
47 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Motion detection scripts | ||
|
||
It is possible to run your own scripts on motion detection by adding your executable script (e.g. `.sh`) | ||
to `config/userscripts/motiondetection` | ||
|
||
When motion is detected, the first argument to the script will be `on` and when motion detection | ||
ends it will receive `off`. | ||
|
||
For example, to send an email containing snapshots on a certain condition, for example | ||
only when the house is empty, you can check an external service (e.g. openhab) | ||
before triggering the email. | ||
|
||
-- sendEmail.sh -- | ||
|
||
```$sh | ||
#!/bin/sh | ||
if [ "$1" == "on" ]; then | ||
source /system/sdcard/config/motion.conf | ||
source /system/sdcard/scripts/common_functions.sh | ||
# Check external service to see it anyone present. | ||
presence=$(curl http://openhab/rest/items/PresenceAtHome/state 2>/dev/null) | ||
if [ "$presence" == "OFF" ] ; then | ||
# No-one is meant to be here, but motion detected. Send email. | ||
/system/sdcard/scripts/sendPictureMail.sh & | ||
fi | ||
fi | ||
``` | ||
|
||
The files should be copied manually, e.g. using ftp. |