Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Automatic image refresh does not work #342

Open
sidamos opened this issue Dec 22, 2018 · 4 comments
Open

Automatic image refresh does not work #342

sidamos opened this issue Dec 22, 2018 · 4 comments
Labels

Comments

@sidamos
Copy link

sidamos commented Dec 22, 2018

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
Copy link
Author

sidamos commented Dec 26, 2018

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

@ghys
Copy link
Member

ghys commented Dec 26, 2018

Looks like vm.original_url could indeed be undefined.

vm.url = (vm.original_url.indexOf('?') === -1) ?

Since it's only defined here - only for static urls:
if (!this.widget.image_source || this.widget.image_source === 'static') {
vm.original_url = vm.url = this.widget.url;
}

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 ghys added the bug label Dec 26, 2018
@sidamos
Copy link
Author

sidamos commented Dec 26, 2018

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.

@LuckyMallari
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants