more G-Labs products

Author Topic: WeMo  (Read 5419 times)

April 13, 2015, 10:53:55 PM
Read 5419 times

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Hi,
I create a script to manage the WeMo Plug. It permit to switch on/off with the add of a virtual switch. And this virtual switch status is updated when the plug is switch on/off by another way than HomeGenie.
Bye

########
A little update for a correction and an add of a try/catch.
« Last Edit: November 12, 2015, 09:26:15 PM by nolio »

September 30, 2015, 05:07:53 PM
Reply #1

boblablah

  • *
  • Information
  • Newbie
  • Posts: 6
The wemo switches have a number of status features now such as usage.  Does this plugin also support querying the meter portion of the device to get stats back as far as power usage through the switch?

September 30, 2015, 10:16:57 PM
Reply #2

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
No only switch on, off, and get the status.

October 27, 2015, 03:07:47 PM
Reply #3

roger.wills

  • ***
  • Information
  • Full Member
  • Posts: 53
Hello again nolio!

I installed and configured your WEMO script on my recently updated HG r498.

Unfortunately it works briefly and then doesn't work and corrupts HG which when restarted seems to have lost all of its configuration.

Furthermore, my HG for android app won't load on the mobile once this has happened.

A simple restore from a previous backup resolves the lost configuration and mobile app issues quickly enough but I am at a loss to know what I am doing wrong regarding the script.

I imported the script. Enabled it and added it as a module to its own group. I configured it with the IP address of the WEMO and that was about it.

Any ideas?

Thanks.

October 27, 2015, 08:41:25 PM
Reply #4

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Hi,
I didn't have the problem (not switch very often).
But i have just try on my side, and HomeGenie seen to crash partially. In my case, a reboot permit HomeGenie to work fine again.
I will try to investigate (when my test environment is ok again).
Bye

October 29, 2015, 10:21:35 PM
Reply #5

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Ok i did some test and it's pretty weird ...
I activate the script and use HomeGenie + switch on/off + do other stuff on HomeGenie => So all work fine.
But when you want to reconnect to HomeGenie nothing appear in the group visualization (but no more too in group and program configuration).

So probably this script break something in HomeGenie, but (for now) i don't know what ...
Gene, perhaps an idea ?

November 05, 2015, 09:11:27 PM
Reply #6

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Hi,
Perhaps a link with the next update in r500 :
Code: [Select]
- Disabled limit of max one opened http connection per program in NetHelperhttps://github.com/genielabs/HomeGenie/blob/master/HISTORY.TXT

I can't really test for now, my test platform doesn't work fine :|
I will try again in r500.
Bye

November 07, 2015, 09:22:50 PM
Reply #7

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Hi,
In r500, that crash again HomeGenie ...

November 07, 2015, 11:51:30 PM
Reply #8

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi nolio, what do you mean by "crash"? :)
Is there any log that could help understand? How many http requests are going out through NetHelper?
Log files are stored in the homegenie/logs folder.

Cheers,
g.

November 08, 2015, 03:34:25 PM
Reply #9

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
After some request view in log like the following, the reload of the HomeGenie UI don't load the contents of the groups, only the Top bar and the configuration menu.
But the switch off and on work fine ...
Code: [Select]
2015-11-08 15:13:04.6634 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/HomeAutomation.WeMo/1/Control.Off/null/ [OPEN]
2015-11-08 15:13:04.6878 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/Media.IpCamera/1/Camera.GetPicture/?1446991981921 [OPEN]
2015-11-08 15:13:04.6705 Info HomeAutomation.WeMo       1       Virtual Module  Status.Level    0
2015-11-08 15:13:05.2237 Info HomeAutomation.HomeGenie.Automation       1038    Automation Program      Program.Notification    {"Title":"WeMo","Message":"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=
\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body>\n<u:SetBinaryStateResponse xmlns:u=\"urn:Belkin:service:basicevent:1\">\r\n<BinaryState>0</BinaryState>\r\n</u:SetBinaryStateResponse>\r\n</s:Body> </s:Envelope>"}
2015-11-08 15:13:05.2278 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/HomeAutomation.WeMo/1/Control.Off/null/ [CLOSED AFTER 0,564 seconds]
2015-11-08 15:13:05.3029 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/Media.IpCamera/1/Camera.GetPicture/?1446991981921 [CLOSED AFTER 0,615 seconds]
2015-11-08 15:13:05.3794 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1038/ [CLOSED AFTER 0,003 seconds]
2015-11-08 15:13:05.3767 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1038/ [OPEN]
...............
2015-11-08 15:14:41.4146 Info HomeAutomation.WeMo       1       Virtual Module  Status.Level    0
2015-11-08 15:14:41.4529 Info HomeAutomation.HomeGenie.Automation       1038    Automation Program      Program.Notification    {"Title":"WeMo","Message":"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=
\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body>\n<u:SetBinaryStateResponse xmlns:u=\"urn:Belkin:service:basicevent:1\">\r\n<BinaryState>0</BinaryState>\r\n</u:SetBinaryStateResponse>\r\n</s:Body> </s:Envelope>"}
2015-11-08 15:14:41.4550 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/HomeAutomation.WeMo/1/Control.Off/null/ [CLOSED AFTER 0,046 seconds]
2015-11-08 15:14:41.6987 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1038/ [OPEN]
2015-11-08 15:14:41.7029 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1038/ [CLOSED AFTER 0,004 seconds]
......

But all the HTTP request are open/close normally, except one like this :
Code: [Select]
015-11-08 15:15:11.3716 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /events [ERROR: Write failure]
2015-11-08 15:15:11.3751 Info WebServiceGateway x.x.x.x      HTTP    GET     200 /events [ERROR: Write failure]

Is it normal that the log file isn't write in real time ?

November 08, 2015, 04:57:45 PM
Reply #10

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Yes it's normal that the log file it is not written in real time.
Can you try this command when the write error occurs?

Code: [Select]
sudo netstat -tupn --all | grep mono | grep tcp

sounds like there are too many opened tcp connections (because the request to wemo are not closing/disposing).

g.

November 08, 2015, 09:31:42 PM
Reply #11

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544

I didn't reproduce this problem again, but i take a look at netstat, so no more than one or 2 connexion at the same time (to the @IP of the plug)  ...

It's a little bit hard to debug, because the script run well but crash partially the HG UI. A restore of backup or a re-install is needed (a reboot doesn't solved the problem).

I have reproduce the problem just by using one time the on (or off) switch function of my script.

I am trying an update of my WeMo plug, but i don't think it will solve the problem.

November 08, 2015, 10:05:39 PM
Reply #12

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
try also recompiling the script after restoring it from the backup, because there were changes in the HG API, so the program might need to be aligned/recompiled for using the new API in a correct way.

g.

November 09, 2015, 09:40:42 PM
Reply #13

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Hi Gene,
No more chance ...  :-\

A capture of the web page after a typical bug, only MIG seems to bug but popup still appear (zwave seems to work fine).
Bye

November 11, 2015, 09:36:59 PM
Reply #14

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Hi,
It's weird because i have 2 similar codes :
  • one to update the status of the plug (off or on ?)
Code: [Select]
  var request2 = Net.WebService("http://"+WeMo_IPAddress1+":49153/upnp/control/basicevent1")
    .AddHeader("Accept", "")
    .AddHeader("Content-type", "text/xml; charset=\"utf-8\"")
    .AddHeader("SOAPACTION", "\"urn:Belkin:service:basicevent:1#GetBinaryState\"")
    .Post("<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\"><BinaryState>1</BinaryState></u:GetBinaryState></s:Body></s:Envelope>");
  var result2 = request2.GetData();
  var virtualMod = Modules.InDomain("HomeAutomation.WeMo").WithAddress("1").Get();
  • One to change the status of the plug : on to off or off to on
Code: [Select]
Action<string,string>
Switchhhh = (string AddressIP, string ONOFF) => {
if ( ONOFF == "on") {
  ONOFF = "1";
}
if ( ONOFF == "off") {
  ONOFF = "0";
}
  try {
  var request = Net.WebService("http://"+AddressIP+":49153/upnp/control/basicevent1")
      .AddHeader("Accept", "")
      .AddHeader("Content-type", "text/xml; charset=\"utf-8\"")
      .AddHeader("SOAPACTION", "\"urn:Belkin:service:basicevent:1#SetBinaryState\"")
      .Post("<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\"><BinaryState>"+ONOFF+"</BinaryState></u:SetBinaryState></s:Body></s:Envelope>");
  var result = request.GetData();

    The first one doesn't crash but the second one (very similar to first one) crash HomeGenie ....

    Any idea ?