HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: domotica_user on September 11, 2015, 02:31:16 PM
-
Dear all,
I have a program running with a When.WebServiceCallReceived(MODULES_DOMAIN, ( args ) and a When.ModuleParameterChanged( (module, property) section. Both contain very little (basically just a: Program.Notify("Widget test", "Test"); ). I have created two widgets and bound them to the appropriate virtual module. So i have a program -> 5 virtual modules -> 2 widgets for virt. mod.1 and 2
Unfortunately, when i click on the switch on my dashboard, nothing happens (i expect a message "Test" popping up). When opening my FF java console i see the following message: "no element found"
What have i forgotten to do?
Thank you very much for your help.
Regards!
-
You can look at that item for guide you on pogramming a new virtual module :
http://www.homegenie.it/forum/index.php?topic=975.msg5938#msg5938 (http://www.homegenie.it/forum/index.php?topic=975.msg5938#msg5938)
Cheers
Dani
-
Hi Dani,
Thank you for your reply. I did see this post yesterday, but as far as i can see i have done exactly that, but the widget is not connected to the program (or virtual module). I have in my program:
- Trigger code: "Program.AddVirtualModules(MODULES_DOMAIN, "Switch", "homegenie/generic/switch", 1, 5)"
- Program code: var myModules = Modules.InDomain(MODULES_DOMAIN); When.WebServiceCallReceived(MODULES_DOMAIN, ( args ) => {
- Inside the WebServiceCallReceived routine i only have a Program.Notify() (to test).
I don't see what i am doing wrong (after reading your suggested post a few times. I hope you can point me in a specific direction. The domains match btw. I checked that a few times.
Thanks again!
-
Perhaps you're modifying the module parameter directly. Indeed, the magic is done by using the Program.RaiseEvent function to update the module parameter. When changing a module parameter directly will just change it silently, will not fire any event, so will not notify to UI and the whole subsystem that the parameter has changed.
http://www.homegenie.it/docs/doxy/a00007.html#a218728a3b9a672b32b46f1e2275cc20d (http://www.homegenie.it/docs/doxy/a00007.html#a218728a3b9a672b32b46f1e2275cc20d)
g.
-
Hi Gene,
Thanks for your reply. What i am doing is clicking on the widget on my dashboard. I expect the program to fire the WebServiceCallReceived routine, or am i mistaken?
Thanks for your reply.
-
http://www.homegenie.it/forum/index.php?topic=1061.msg6408#msg6408 (http://www.homegenie.it/forum/index.php?topic=1061.msg6408#msg6408)
yes it should hit the WebServiceCallReceived routine.
Open the web browser debugger to see what url is called when you hit the buttons.
Paste it here along with the code you currently implemented.
g.
-
The following url is called:
http://10.x.x.93/api/HomeAutomation.Homeduino/1/Control.On/null/1441978679182?_=1441836391792 (http://10.x.x.93/api/HomeAutomation.Homeduino/1/Control.On/null/1441978679182?_=1441836391792)
I have attached the program and trigger code.
I hope you can help me with this. Thanks!
-
You are missing the
Program.GoBackground();
instruction at the end of your program code.
Otherwise the program will exit. You will know that is running in the background because the led light will turn green.
g.
-
The way you're using ModuleParameterChanged is not correct. This is supposed to be used for listening to module events, for instance when you turn on a module the Status.Level parameter will change to 1.
When.ModuleParameterChanged( (module, property) => {
Program.Notify("Homeduino switch", "Test2");
if (module.Instance.Domain == MODULES_DOMAIN )
{
int lightnumber = Convert.ToInt32(module.Instance.Address);
switch (property.Name) {
case "Meter.Watts":
Program.Notify("Homeduino switch", "Meter.Watts = " + property.Value);
break;
case "Status.Level":
Program.Notify("Homeduino switch", "Status.Level = " + property.Value);
break;
default:
break;
}
}
return true;
});
when you click the ON button the "Control.On" command will be called, and so the WebServiceCallReceived function will perform
Program.RaiseEvent(module, "Status.Level", 1, "My Light");
causing the module Status.Level change to 1.
g.
-
I now see you took the code from the MyLight program. Well this is a program contributed by a forum user, and I didn't notice of the errors in it till now.
A better working example would have been the Philiphs Hue program.
g.
-
It is fixed now. Gene, because of your remark of the missing Program.GoBackground(); i started looking into that (i HAD a green light, so why not working?).
It turned out that i was using a while(1) { sleep(); } and that was BEFORE the ModuleParameterChanged, so it never reached this section of code. Very silly of course, but all is well now :)
Thank you for helping me, i can start coupling the widgets with my hardware interface now.
BTW: Dutch users: I am using the Homeduino interface to have a Klik Aan Klik Uit (KAKU) interface for Homegenie. When this is working properly i will contribute the program to this project, but if you have questions about my kaku research, please let me know. I will help you setting stuf up.