org.openhab.ui.habpanel icon indicating copy to clipboard operation
org.openhab.ui.habpanel copied to clipboard

Automatic image refresh does not work

Open sidamos opened this issue 6 years ago • 4 comments

I have an image widget with an openHAB String item which contains a snapshot url for my Nest camera and I have set auto refresh to 60 seconds.

Instead of refreshing the image, I get this in the browser console: vendor.js:119 TypeError: Cannot read property 'indexOf' of undefined at image.widget.js:70 at n (vendor.js:108) at m.$eval (vendor.js:147) at m.$digest (vendor.js:144) at m.$apply (vendor.js:147) at vendor.js:109

When I enable No Cachebusting, then I don't get an error in the browser console, but the image goes black after 60 seconds.

Using openHAB 2.4.0. Tested on newest Chrome version on Linux and Android.

sidamos avatar Dec 22 '18 21:12 sidamos

I did further testing and auto refresh does work if I use the Nest URL as a static URL instead of from an openHAB String Item.

For an example on how the image URL looks like (I deleted some chars here and there, so that it does not really work with my camera):

https://www.dropcam.com/api/wwn.get_snapshot/CjYtbXFPZXFVDaXp6eWJoOENHcEJKWEhqWE5Nb2Q2ZlBsTlZo4Z2x6YjVsNWhYcamcSFjdCejZHSHFtdXV4ZzlKUmlweUZVY1EaNm1SSlFPWjlVMHNxNnoweW5GMkhCLWsyOGE5NWdxRTWI5ZF83YnI2MTRLX25rQ2FCNERlQQ?auth=462ZAS4JeGb7hg6yK3siAVwiiz-xTomCKQKEUnVJ5BLB5ANy_a-7fcwF3ysEVMOyjGDY0tgJR_rrtQSvTl_P7JYVnl4QYzJRpttyqKAOAf41nyB7DjZ9_RW62fNFJ1Bh_VTz4qOBrEEABfNdtdmAkTE1sRq_F2hE0TZB9l7M0C80dY0mf3W3upZfXaM-3ns

sidamos avatar Dec 26 '18 10:12 sidamos

Looks like vm.original_url could indeed be undefined. https://github.com/openhab/org.openhab.ui.habpanel/blob/7fbdf026e18656ede362351d44267bce844e665b/web/app/widgets/image/image.widget.js#L70 Since it's only defined here - only for static urls: https://github.com/openhab/org.openhab.ui.habpanel/blob/7fbdf026e18656ede362351d44267bce844e665b/web/app/widgets/image/image.widget.js#L58-L60 This was introduced in #143. I think the rationale at the time was that if you're specifying a String item, you're responsible for autoupdating it via rules instead of relying on the widget's autoupdate. Nonetheless, it's still a bug.

ghys avatar Dec 26 '18 10:12 ghys

At the moment, I am using a time triggered rule as a workaround, but it is very hacky:

rule "Nest Snapshot Refresh" when Time cron "0 0/5 * * * ?" // every 5 minutes then var orig = FrontDoorCameraNestHello_Camera_SnapshotURL.state.toString FrontDoorCameraNestHello_Camera_SnapshotURL.sendCommand("/static/black.jpg") Thread::sleep(500) FrontDoorCameraNestHello_Camera_SnapshotURL.sendCommand(orig) end

It is necessary to really change the URL and the sleep is also necessary, otherwise it won't update.

sidamos avatar Dec 26 '18 11:12 sidamos

I will check if we can add input validation on the widget configuration when I get on a PC.

LuckyMallari avatar Jan 13 '19 13:01 LuckyMallari