An image is downloaded from a webcam via wget stored in /tmp/ and afterwards send out via sendMail from file:///tmp/ - that works since years thanks to @watou and here
The plan was to display the downloaded file in the sitemap, too, which I couldnt figure out how.
- An url in the sitemap to /tmp/picture.jpg did not work (Mail action can take the file, the sitemap not). See here
- Storing the file with wget in /etc/openhab2/html where the url in the sitemap can take it from, did not work. See here
Maybe you have a better solution than putting a symbolic link between /tmp/picture.jpg and /etc/openhab2/html/picture.jpg (ln -s /tmp/picture.jpg /etc/openhab2/html/picture.jpg). This makes the picture available for a sitemap entry with url to localhost/static/. Disadavantage is that this has nothing to do with OH and will not be saved within any OH config. Just wanted to leave this to the community to discuss better solutions.
Sitemap entry is:
Text label="Klingelbild" icon="camera" {Image url="http://192.168.178.58:8080/static/picture.jpg"}
Rule to download the picture and send it via mail is:
rule "Wenn es am Tor klingelt, schicke eine e-mail"
when
Item Tor_Klingel received command ON
then
{
var picture = "picture.jpg"
var doorbellmessage = "Es klingelte um "+ now.toString ("HH:mm dd-MM-yyyy")
executeCommandLine("wget http://user:pass@192.168.178.51:8080/?action=snapshot -O /tmp/" + picture)
Thread::sleep(3000)
sendMail("me@mail.de", "Es klingelte am Tor", doorbellmessage, "file:///tmp/" +picture)
}
end