IPCam image does not refresh

Begonnen von Martijn, 08 Dezember 2016, 15:37:50

Vorheriges Thema - Nächstes Thema

Martijn

Hi,

I made it possible to control my IPCam/webcam via FHEM. However when the snapshot/image is refreshed the weblink-image does not refresh. Propably this is due to a normal 'web'-issue. And it can be solved by adding a timestamp or randomizer like '...\snapshot.jpg?20161112_120000'.

But how can I add this to the link in the weblink-module.

See below my codes:
defmod ipcam_kids IPCAM 192.168.0.16
attr ipcam_kids alias Kids Cam Pan/Tilt
attr ipcam_kids cmdPanLeft command=4
attr ipcam_kids cmdPanRight command=6
attr ipcam_kids cmdPos01 command=33
attr ipcam_kids cmdPos02 command=35
attr ipcam_kids cmdPosHome command=31
attr ipcam_kids cmdStep onstep
attr ipcam_kids cmdTiltDown command=2
attr ipcam_kids cmdTiltUp command=0
attr ipcam_kids delay 1
attr ipcam_kids icon it_camera
attr ipcam_kids path snapshot.cgi
attr ipcam_kids pathCmd set_misc.cgi?user=USER&pwd=PWD
attr ipcam_kids pathPanTilt decoder_control.cgi?user=USER&pwd=PWD
attr ipcam_kids snapshots 6
attr ipcam_kids storage ./www/snapshots
attr ipcam_kids timestamp 0
attr ipcam_kids webCmd pos home:pos 1:pos 2


and for displaying:
defmod webcam_picture weblink image /fhem/snapshots/ipcam_kids_snapshot.jpg?$DATE
attr webcam_picture alias Webcam kids
attr webcam_picture htmlattr width="100%"

setstate webcam_picture initialized

Thus the above "$DATE" should be a variable thing. Is this possible?

rudolfkoenig

ZitatThus the above "$DATE" should be a variable thing. Is this possible?
It would not do what you expect.

The weblink module generates an HTML <image src="..."> tag, which "sits" in the Browser for indefinite time, there is no action associated with it.
If the image is displayed all the time, e.g. in a static wall-mounted display, than a FHEM-at-instance could start the following every X minute:
trigger WEB JS:$("img[src*=ipcam_kids_snapshot").attr("src","/fhem/snapshots/ipcam_kids_snapshot.jpg?ts="+(new Date()).getTime());

As an alternative, you could include your own JavaScript, replacing the FHEM at and trigger.
In an ideal world the weblink module would generate this JavaScript code, and you could specify the refresh interval via an attribute.