This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Updating and activating App from Lua Script
#1
Hi,
I have made some changes to the database that we are using. With the database changes made
using lua scripts the results don't appear in the Objects Web page until I perform a Browser
refresh (F5). Even after this the objects don't reflect their live status until the hardware
is rebooted. I realise this is 2 issues but am hoping to deal with them both using the lua
scripting. Can anyone please suggest what I need to do here. It's not SQL based rather refreshing
the GUI and re-loading the database. Are there finctions in a library somewhere perhaps?
I hope this isn't a silly question and thank you to anyone who can spare the time.
Stevo
Reply
#2
Hi,

I have a custom JS that you can use to refresh the browser by a knx object (write to this object from LUA script), after adding that you need to refresh the browser once to load it.

I will post it later today.

For the database issue you are facing we need some info what you are doing as a browser refresh should and does always result in a actual object state, never seen other values then actual db values.

I think you do something strange that causes that..

BR,

Erwin
Reply
#3
Check if browser error console (opens by pressing F12) has any errors.
Reply
#4
Hi Erwin,

I’m very interested in your custom JS for refresh the browser Big Grin 

BR
Jean-Marc
Jean-Marc
Reply
#5
Hi,

Here is the custom JS to refresh the browser by KNX command:
Code:
$(function(){
if (typeof grp != 'undefined') {
   grp.listen('32/0/1', function(object, state) {
     var value = object.value;
     if (state == 'value') {
       if (value == true) {
         location.reload();
       }
     }
   }, true);
}
});
Be sure to refresh the browser once to have this loaded after you have added it.

BR,

Erwin
Reply
#6
Hi,

thanks Erwin

This is the code I use and sometimes reloading from the server is not done even with "location.reload(true)"

BR
Jean-Marc.
Jean-Marc
Reply
#7
Hi,

Have you checked with console that the function is called?

Also in this sample is at the end of the grp.listen a extra parameter ‘true’, this makes the action executed by the same object value, if it is not in your version you might send only true and then it won’t be triggered, so try this version first as i never heared it doesn’t work.

BR,

Erwin
Reply
#8
Hi,

I didn’t say that it doesn’t work, I said that sometimes "location.reload(true)" is done on the cache and not on the server.
I did some research on it but I couldn’t find anything.

Br
Jean-Marc.
Jean-Marc
Reply
#9
Hi,

Custom JS is never executed on the server side, it’s just a piece of JS that is injected into the HTML that is loaded by the client(s) and executed by the browser. So it runs always client side.

Once loaded by the browser it should always execute and cache has nothing to do with that, check the HTML source code if it’s inserted correctly, then it should work every time it’s triggered.

Only reason that might not trigger it after being loaded is a interupted websocket but that would also stop all other object updates.

BR,

Erwin
Reply
#10
Hi,

I think we do not understand each other ...

Just look
https://www.w3schools.com/jsref/met_loc_reload.asp

BR
Jean-Marc
Jean-Marc
Reply
#11
Hi,

Aah, Okay, the difference in the ‘true’ parameter is that the browser loads the page default from cache and not everything from the server, so it will use images and other source files like css from the cache to avoid unneeded load.

In both cases the function should always be triggered, when you have added for example new images with the exact same name or other updated files with exact same names it will not be replaced by a reload as the browser asumes the files it already has are latest. In that case you need to add the parameter true to force the browser to download all files anyhow.

In either scenario the browser should reload and you should notice a blink of the refresh, thats why i say to use the console to check it.

BR,

Erwin
Reply


Forum Jump: