fun4stuff, I would really appreciate a step-by-step for this. I was an early (Kickstarter) adopter of Smartthings and just happen to have a ST motion detector right above my kegerator, controlling the garage lights. Ideally I'd like the screensaver to put the monitor into powersave mode rather than play videos, but I'll take whatever you're offering...
TIA!
1. Basically, you install Webhooks and XScreenSaver on the pi.
I followed instructions here:
https://github.com/adnanh/webhook/blob/master/README.md
Code:
apt-get install xscreensaver
2. Set up a .json file (tells pi to run .sh script when URL is run) and .sh script (telling XScreenSaver to deactivate and to play beer pour mp3 using mpg123 or cvlc) for Webhooks.
Code:
[
{
"id": "motion",
"execute-command": "/home/pi/webhooks/motion.sh",
"command-working-directory": "/home/pi/webhooks”
}
]
Next create motion.sh, which is the script run when URL is accessed.
Code:
#!/bin/sh
Sudo xscreensaver-command -deactivate
cvlc --no-video-title-show /home/pi/Documents/beer.mp3
You could also adapt code from the following URL to put monitor into/out of powersave mode. I currently have it set up so monitor is on/off with my basement lights (via smartthings.
https://pastebin.com/jcEzLUB4
Code:
Off:
xset dpms force standby
vcgencmd display_power 0
On:
display_power 1
You then have to make motion.sh executable.
3. Run the Webhooks server. That listens for URL and runs the script if url accessed.
Code:
/path/to/webhook -hooks hooks.json -verbose
You can run multiple json files too. EG:
webhook -hooks /home/pi/Webhooks/hooks.json -hooks monitoroff.json -hooks monitoron.json -verbose
You run the script by accessing the following URL:
Code:
http://localIPaddressOFpi:9000/hooks/motion
4. Then setup in smartthings a virtual button that runs URL when triggered. Then in Smartthings set so that when motion detected, virtual button is pressed.
Log into smartthings web IDE.
Go to device handler section and create a new device handler from code. Paste code in from following web address and publish for yourself.
https://github.com/ruricu/SmartThings/blob/master/uributton.groovy
Then go to device section and create a new device. Fill in names in the sections that have asterisks. Then choose type from drop down and choose URIbutton (will probably be near bottom). Then save it.
Then go into smartthings app on your phone and find the device you just created. Click gears in top right to set up and fill in according to URL above:
Internal IP: localIPaddressOFpi
Internal port: 9000
Internal path: /hooks/motion
This creates a button device in smartthings. When it’s pushed or ran with an automation, the URL is run and webhooks server will run above script.
5. You then set up XScreenSaver to play video(s) using VLC (supposedly you can use mpv to play videos, but wasn’t working for me).
Add:
Code:
"Videos" cvlc --loop --fullscreen --drawable-xid \
$XSCREENSAVER_WINDOW \
--no-video-title-show \
/path/to/videos.mp4
I think most of the above is correct. On vacation at the moment and my pi is off. So above is from memory.
You could probably have your motion.sh file turn on your monitor’s hdmi with code above. Then in smartthings setup an automation script that runs when there has been no motion after X minutes and have it run a webhooks URL that activates a script that turns the hdmi to Monitor off.
This was easier for me than adding a PIR motion to the pi since i already had an extra zwave motion detector, smartthings and all my lights and outlets in my house are zwave and automated with smartthings. Gives me more flexibility (e.g. turn on/off taplist monitor automatically when my basement lights are on/off, shut down my pi every night at 2 am and turn back on at 5 pm, etc).