more G-Labs products

Author Topic: C# WebServiceCallReceived help please  (Read 1256 times)

November 02, 2014, 08:20:36 PM
Read 1256 times

jshan

  • ***
  • Information
  • Full Member
  • Posts: 71
I'm writing a C# program in HG and I'm having a problem with:

When.WebServiceCallReceived("HomeAutomation.HomeGenie.Automation", ( args ) =>
{
  return true;
}

Once I enable my program, without doing anything else, the security system stops responding to its control widget though the widget itself changes Armed/Disarmed.  To get the security system to work again, I have to disable my program and restart the security system.  If I comment out the When.WebserviceCallReceived section in my program, everything works fine.  I notice that the security system also uses "HomeAutomation.HomeGenie.Automation" but I thought my "return true" would allow the call to drop through.

So, I thought maybe I could use something different than "HomeAutomation.HomeGenie.Automation".  I noticed other programs use a more specific string, like: "RaspberryPi.Gpio".  But I don't know what to use.  My program is in group: "Messaging and Social" and is named: "Android Push Notification".

I have another When.WebServiceCallReceived("APNRequest", ( args ) => which works fine from a browser call and does not seem to interfere with the security system.

The reason I need WebServiceCallReceived("HomeAutomation.HomeGenie.Automation", ( args ) => is so that I can have a control widget which, when pressed, will execute the code in the WebServiceCallReceived.  If I ignore the issue with the security system and go ahead with the WebServiceCallReceived, and implement a switch widget via:

Program.AddControlWidget("homegenie/generic/switch");

then I can see the WebServiceCallReceived working fine.  But, of course, I need my security system working too.

I'd also like to just use default widget as I don't need a switch, just a button.  But when I tried the default widget, the WebServiceCallReceived in my program did not seem to get called.

So, any ideas on the WebServiceCallReceived and/or the default widget?

Any help would be greatly appreciated.

Thanks,
John

March 18, 2015, 03:44:35 PM
Reply #1

NickP

  • *
  • Information
  • Newbie
  • Posts: 24
You should be returning a valid RESt response e.g.

return "{ 'ResponseValue' : 'OK' }"; 

March 18, 2015, 07:35:27 PM
Reply #2

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi John,


When.WebServiceCallReceived("HomeAutomation.HomeGenie.Automation", ( args ) =>
{
  return true;
}


registering the whole ""HomeAutomation.HomeGenie.Automation" path, will cause problems to other automation programs.  Use the following formula instead:

Code: [Select]

When.WebServiceCallReceived(Program.Module.Domain + "/" + Program.Module.Address, (args) =>
{
    // ...
}


g.