OpenHab and IP Camera - Snapshot URL Authentication

Scenario:
Motion sensor goes off, OpenHab grabs images from the IP Camera’s snapshot URL and emails them.

Camera: Trendnet IP 672WI
Snapshot URL: (http://User:PW@192.xx.xx.xx:80/image/jpeg.cgi)

If i turn ON SnapShot URL authentication, I can embed the image into my sitemap if i insert the user/pw in the url.
http://User:PW@192.xx.xx.xx:80/image/jpeg.cgi
I can navigate to the sitemap and see the snapshot.

However, If i try to use the email function in a rule, no image is sent.
If i turn off SnapShot Authentication on the camera, email starts working(sending pics).

Why can the url load in the sitemap and display the picture, but via email its blocked?

Rule Code:
sendMail("bla@blal.com", "FD-Picture1-Motion " + now, "Here is your 1st picture: ",“http://User:PW@192.xx.xx.xx:80/image/jpeg.cgi”)

It will send pic when snapshot auth is off, on the camera
Will not send pic when snapshot auth is on, on the camera
It will embed the pic in a sitemap(image) either way

I am using 1.8.3 of orb.openhab.action.mail

sendMail isn’t compatible with simple authentication of this kind. You have to download the image locally and then sendMail it

Dan

Thanks, do you know of any applicable addons to do such a thing with some examples?

Appreciate the feedback.

-Rich

I do it like this:

executeCommandLine("bash /etc/openhab/configurations/get_street_image.sh")
sendMail("address", "Automation: street camera alert", "","file:///tmp/street.jpg")

and then get_street_image.sh is as follows:

#!/bin/bash
wget http://username:password@street_IP_cam/dms -O /tmp/street.jpg

I use a bash script rather than running wget through another executeCommandLine because I always found executeCommandLine flaky and pedantic in how it wants strings formatted.

I’m confident others will have more elegant solutions!

1 Like

I do exactly the same!