more G-Labs products

Author Topic: Program.RaiseEvent("Program.UiRefresh"...)  (Read 2212 times)

November 29, 2015, 04:16:58 PM
Read 2212 times

DavZero

  • **
  • Information
  • Jr. Member
  • Posts: 48
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.

November 29, 2015, 06:14:22 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
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).

November 29, 2015, 11:35:10 PM
Reply #2

DavZero

  • **
  • Information
  • Jr. Member
  • Posts: 48
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
« Last Edit: November 30, 2015, 05:32:17 PM by DavZero »

November 30, 2015, 04:50:20 PM
Reply #3

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
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.

November 30, 2015, 07:46:23 PM
Reply #4

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
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.
« Last Edit: November 30, 2015, 07:48:19 PM by Gene »

December 01, 2015, 08:35:04 PM
Reply #5

DavZero

  • **
  • Information
  • Jr. Member
  • Posts: 48
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
« Last Edit: December 01, 2015, 08:39:43 PM by DavZero »

December 04, 2015, 08:41:33 AM
Reply #6

maxflax

  • ***
  • Information
  • Full Member
  • Posts: 90
Is this implemented in the last version 504?

December 04, 2015, 04:54:57 PM
Reply #7

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I believe Gene said it would be in the next release which would be r505 presumably.

December 04, 2015, 06:50:25 PM
Reply #8

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
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

December 05, 2015, 01:46:51 PM
Reply #9

DavZero

  • **
  • Information
  • Jr. Member
  • Posts: 48
Hi,

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

Thanks again Gene for your works and your availability.