Download Image with a rule?

hello,

is it possible to download a image with a rule and rename it after download?

regard

On what system? You can create a script bash/python/node/etc and trigger/run them with the Exec binding

on my raspberry (openhab server)

background is this:

so, i need a solution in openhab, if possible.

regard

i try this, but will not work

rule "download image"
when Time cron "0/30 * * * * ?"
then
executeCommandLine("curl -L 'http://192.168.1.226/dyn/render_image?q=jobs&id=29&slug=ANET2' -o /home/openhabian/repetier.jpg")
end

LOG is good, no error

2018-03-14 21:56:30.036 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine 'curl -L 'http://192.168.1.226/dyn/render_image?q=jobs&id=29&slug=ANET2' -o /home/openhabian/repetier.jpg'

but there is no download

if i use the command in my ssh-terminal, it works fine

[21:53:28] openhabian@openHABianPi:/tmp$ curl -L 'http://192.168.1.226/dyn/render_image?q=jobs&id=29&slug=ANET2' -o /home/openhabian/repetier.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  453k    0  453k    0     0  5691k      0 --:--:-- --:--:-- --:--:-- 5815k
[21:57:38] openhabian@openHABianPi:/tmp$

Does your openhab user have write permissions on the openhabian folder?

I suppose you’re trying to show the image on your screen?

@pahansen

i think so, i had try the openhabian home path and tmp folder. both dont work

@luckymallari

yes, but the url is dynamic. the first attempt is to download the image via a rule. the
second to change the url to the correct path (the ID in my path can be different)

but, i ve now problems with the first step.

What UI are you using?

Maybe take a look at this post.

BasicUI

Give the command some time to execute:
Add time at the end, 5s should be sufficient:

executeCommandLine("curl -L 'http://192.168.1.226/dyn/render_image?q=jobs&id=29&slug=ANET2' -o /home/openhabian/repetier.jpg", 5000)

1 Like

works, thx

but next problem, how can i add a local image to openhab?
image is in tmp folder

Image url="/tmp/repetier.jpg" refresh=10000

this dont work

Put the image in the conf/html folder

Yup. Thats what I would do.

Or you can use HABPanel and use the URL (http://192.168.1.226/dyn/render_image?q=jobs&id=29&slug=ANET2) itself on an image widget