Hello,
I’m working to integrate an interesting feature on my system.
Basically when the door rings, the ip cam take a picture and send me via push notification.
I’m quite in a good situation;
the cam is UP, and I’m able to save a screenshot when a trigger happends, on etc/openhab/html/ folder.
I’m not able to find the correct syntex to send via push notification the saved .jpg file.
Here the code:
rule "Send doorbell"
when
Item MQTTSonoff_DOORBELL changed from OFF to ON
then
executeCommandLine("wget", "http://LOCALIP:8080/ipcamera/19f344ea7a/ipcamera.jpg", "-O", "/etc/openhab/html/CamDOORBELL.jpg");
sendBroadcastNotification("Door ringsapartment!", "Door", "Door Tag",
"RingDetected", "door-id-1234", null, "file:///etc/openhab/html/CamDOORBELL.jpg",
null, null, null)
end
the part:
“file:///etc/openhab/html/CamDOORBELL.jpg”,
is not correct… the file is not correctly grabbed and sended to me…
I find it in that Similar Example
but in my case not working correctly
Someone know the correct syntex to use to send the .jpg file that is saved on the raspberry where OH is?
Yes it works but only if i connect my android phone with OH app in the same network, otherwise the image is not displayed…
I’m searching a workaround to see the image anyway…
maybe populate an “image” item and display the item in the push could be an idea?
Free as in free beer? Yes, for the first 30 days, then it is a one time payment of 5 USD.
I paid that about 10 years ago and it was a very good investment.
My doorbell camera is connected to the IPCamera binding and sends me an animated gif of 5 seconds lenght if someone rings the bell.
You can even have a short mp4 video sequence.
BTW, I pay for every free opensource service, if I tend to use it for a longer period of time. Just to show the appreciation for that marvelous work these guys do!
Ok, just for reference I made it works from the scratch here my example:
no external services needed
import java.net.URL
import java.util.Base64
rule "Send doorbell push with pics"
when
Item TRIGGERING_ITEM changed from OFF to ON
then
executeCommandLine("wget", "http://192.168.178.175:8080/ipcamera/19f344ea7a/ipcamera.jpg", "-O", "/etc/openhab/html/CAM.jpg");
val imageUrl = "http://192.168.178.175:8080/static/CAM.jpg"
val username = "YOURopenhabianUSER"
val password = "YOURopenhabianPASS"
val url = new URL(imageUrl)
val connection = url.openConnection()
val userpass = username + ":" + password
val basicAuth = "Basic " + new String(Base64.getEncoder().encode(userpass.getBytes()))
connection.setRequestProperty("Authorization", basicAuth)
val contentType = connection.getContentType()
val bytes = connection.getInputStream().readAllBytes()
val image = new RawType(bytes, contentType)
TestImage.postUpdate(image)
sendBroadcastNotification("Motion detected in the apartment!", "motion", "Motion Tag",
"Motion Detected", "motion-id-1234", null, "item:TestImage",
null, null, null)
end