HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: DavZero on November 29, 2015, 04:16:58 PM

Title: Program.RaiseEvent("Program.UiRefresh"...)
Post by: DavZero on November 29, 2015, 04:16:58 PM
Hi,

I've seen in antoher post (about notification flood on weather widget)  that a there is a "new" way to udpate widget value without generate notification.
It's by using :
ModuleParamter1.Value = "toto";
ModuleParameter2.Value = "titi";
Program.RaiseEvent("Program.UiRefresh","Data updated","");

I've try this in HG 1.1 v503 but the widget doesn't refresh itself, I must change page a display again the widget to see the updated value.

Is there something I miss?
How HG know which widget refresh?

Thanks.
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: bkenobi on November 29, 2015, 06:14:22 PM
I have a similar experience that my widgets don't seem to update until I change pages or press the refresh button on the web browser (which then reloads the whole session).
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: DavZero on November 29, 2015, 11:35:10 PM
I understand more on a discution with gene (thanks again to him to take time for explain that):

If a widget must be updated without notify for each values contain in the widget, we should do it like this :

Code: [Select]
moduleParam1.Value = "test1";
moduleParam2.Value = "test2";
moduleParam3.Value = "test3";
//Update the UI
RaiseEvent(module,"Program.UiRefresh","Data updated","");

But I discover that some widget ignore this event, it's the case for example for the widget homegenie/generic/sensor

Can anyone tell me where this is define? If there is other widget that ignore some event (I think I could answer alone if I have the response for the first question ^^)? and why ?

This behavior of the generic/sensor widget seems to be a bad limitation because for example I've made a program for manage my RFX433 temperature/humidity sensor and I've use the homegenie/generic/sensor to display the data. The sensor send data really often (Everytime a modification append) but I doesn't like to have 3 notifications (temp/hum/batt) that append every 30 seconde approximatly for all my sensor (3 actually), so I planned to modify my program for use the new refresh event but it seems to be impossible with the "standard widget".

Thanks
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: bkenobi on November 30, 2015, 04:50:20 PM
I use the same sensor for my weather station, UPS monitor, and your CPU load APPs.  I have seen the same issue with all of them recently though it's not generally an issue for me since I use the statistics viewer to visualize the data over time.  However, it would be nice if the data were kept up to date should I leave the HG web interface active and come back to it later.
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: Gene on November 30, 2015, 07:46:23 PM
After some investigation I found out that there was actually an issue with "Program.UiRefresh" event.
It would only work for program modules.
Now the ui refresh event will work with any kind of modules (interface modules, and virtual modules as well).
So it was not a problem of the generic sensor widget (sorry about addressing a wrong issue :)).
I'm attacching the _event.js patched file, in case you want already test the fix. Simply copy it over the old file in the homegenie/html/pages/events folder.
Note that using the Program.UiRefresh event and changing the value of a parameter directly without using the RaiseEvent method, it will only notify the UI that the widget needs to be refreshed, while the parameter change will never be notified to the system. For example it won't be caught by  When.ModuleParameterChanged .
In next hg update there will be another way of calling the RaiseEvent without making it popup in the UI;
Code: [Select]
Program.RaiseEvent(myModule, "Status.Level", "1", ":nopopup:Optional event description");
the ":nopopup:" option at the start of the description field, will prevent the popup from being shown but it will still raise the event in the system.

g.
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: DavZero on December 01, 2015, 08:35:04 PM
OK thanks for the explanation it's more clear and i understand now that use the uirefesh was probably not what i want for the température sensor but seems to be great for the system sensor (not needed to propagate this or perhaps just for alert ). So it's good to heard that's on a next release there were a new way to raise évent without notify.
 I will test the _event.JS as soon As i can (but not today sorry).

Bye
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: maxflax on December 04, 2015, 08:41:33 AM
Is this implemented in the last version 504?
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: bkenobi on December 04, 2015, 04:54:57 PM
I believe Gene said it would be in the next release which would be r505 presumably.
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: kevin1 on December 04, 2015, 06:50:25 PM
505 is out
-Added ":nopopup:" option to disable notification popup on RaiseEvent (":nopopup:" must be specified in the description field)
-Fixed "Program.UiRefresh" event, that was working only for program modules
Title: Re: Program.RaiseEvent("Program.UiRefresh"...)
Post by: DavZero on December 05, 2015, 01:46:51 PM
Hi,

I've test both solution and all is working on v505.

Thanks again Gene for your works and your availability.