The URL in the above line is what motionEye provides for a snapshot. It works fine every time if I try the same URL in a browser.
However, I get the email from openHAB, but 90% of time the image is garbled (looks like a modern painting ).
I tried to experiment with different image resolutions in motionEye, but with no luck.
I want to implement this as an action after motion is detected with a zwave motion sensor configured in openHAB, but this poor reliabiity is unacceptable.
How this can be tuned to get clear images all the time ?
I am new to openHAB and any suggestion would be appreciated.
rule "MotionDetected"
when
Item PorchMotionDetected changed from OFF to ON or
then
val url = "http://192.168.2.97:8765/picture/2/current"
val outputFile = "/srv/data/openhab/snaps/" + now.toString +".jpg"
var cmd = "curl -m 10 -o " + outputFile + " " + url
executeCommandLine(cmd)
Thread::sleep(1000)
sendMail("jason.brunk@gmail.com", "Motion", "There is motion", "http://192.168.2.97:8765/picture/2/current")
end
I found that the screen caps were not garbled if I was watching the stream at the same time. Not sure why. But it was clear if someone was watching the stream. So I thought to try maybe grabbing a screen to “kick start it” before attaching to email.
I have it grab a screencap, wait 1 second. send a snap. Seems to work. I tried to grab a cap, store local then send. But that one was garbled too. Happened even if I ran the curl command by hand. 1st one garbled. 2nd was fine.