Author Topic: Eco Plugs  (Read 10339 times)

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Eco Plugs
« on: January 26, 2016, 08:25:18 pm »
I recently picked up some wifi-controlled outlets called KAB "Eco Plugs" manufactured by a chinese company KAB a few weeks back at Home Depot. They were crazy cheap (2 for $5) and work through use of an app on your home wifi network. You can also buy them on other sites like walmart:

http://www.walmart.com/ip/46721978

I've been trying to figure out what protocol they use so I could try to integrate them into Vera. I did some basic packet captures and I believe they are sending udp traffic on port 80. FYI, someone has figured out how they communicate, and has written a plugin for homebridge (a HomeKit emulation server). The plugin info is here:

https://www.npmjs.com/package/homebridge-ecoplug4
https://github.com/Danimal4326/homebridge-ecoplug4

I can confirm that it works, as I have homebridge running, and am able to control my Eco Plugs using the homebridge-ecoplug plugin (very cool plugin BTW). However, I am not good enough at reading code to actually see what is being sent/received. If you look at the github page, there is an index.js file that contains all the code. If there is anyone that is versed enough to look javascript and figure out what is being sent/received, I would love to know what the actual http commands being sent are too. Thanks in advance for any help that can be provided!

Offline cybrmage

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +105/-5
Re: Eco Plugs
« Reply #1 on: January 27, 2016, 01:39:17 am »
So... I needed a change of pace... and recently implemented a similar device (SengLED Boost bulb)...

and came up with an implementation for these devices...

1) On your Vera, go to Apps/Develop Apps/Luup Files, and upload the attached implementation file.
2) On your Vera, go to Apps/Develop Apps/Create Device.
3) Fille in the parameters as follows:
    Device Type:  urn:schemas-upnp-org:device:BinaryLight:1
    Internal ID: (enter the name of your switch ie: ECO-XXXXXXXX)
    Description: (enter the name you want for the plug - if left blank, it will be names "_Binary Light")
    Upnp Device Filename: D_BinaryLight1.xml
    Upnp Implementation Filename: I_ECO_Switch.xml
    IP address: (enter the IP Address of your ECO plug)
4) Click on "Create Device"
5) Allow the LuaUPnP engine to reload and refresh your browser.

You should then be able to control the switch directly from your Vera.



** Faulty attachment removed **
« Last Edit: January 31, 2016, 07:39:24 pm by cybrmage »
EVL3Vista - Wink Connect - Caseta Connect - Venstar Colortouch - WiFi UDP Switch Controller - Broadlink RM - MyQGateway

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Re: Eco Plugs
« Reply #2 on: January 27, 2016, 10:25:53 pm »
Thanks so much for putting this together!! I'm traveling at the moment, but I will give it a shot as soon as I'm able and report back how it works. Thanks again!

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Re: Eco Plugs
« Reply #3 on: January 29, 2016, 07:17:11 pm »
So I finally had some time to try this today, doesn't work  :-\ I get "Lua Engine Failed to Load" error at the top of the screen. I'm running latest UI7, and have debug logging enabled. I ssh'ed into my Vera and looked at the LuaUPnP log. I don't see anything jumping out, but I'm not sure I'm looking for the right things either. I don't see anything in there related to the XML file you put together. Any advice on what I should be looking for?

Offline cybrmage

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +105/-5
Re: Eco Plugs
« Reply #4 on: January 29, 2016, 07:43:27 pm »
I ssh'ed into my Vera and looked at the LuaUPnP log. I don't see anything jumping out

You'll need to post the log... I don't have these devices... so i'm working blind...

EVL3Vista - Wink Connect - Caseta Connect - Venstar Colortouch - WiFi UDP Switch Controller - Broadlink RM - MyQGateway

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Re: Eco Plugs
« Reply #5 on: January 29, 2016, 08:27:54 pm »
see attached, is this what youre looking for? Thanks again!

Offline cybrmage

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +105/-5
Re: Eco Plugs
« Reply #6 on: January 29, 2016, 09:04:35 pm »
I checked over the code... I made a small error in the translation nodejs to lua...

The fixed file is attached...

** Faulty attachment removed **
« Last Edit: January 30, 2016, 04:58:43 pm by cybrmage »
EVL3Vista - Wink Connect - Caseta Connect - Venstar Colortouch - WiFi UDP Switch Controller - Broadlink RM - MyQGateway

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Re: Eco Plugs
« Reply #7 on: January 29, 2016, 10:57:57 pm »
Removed old XML file and readded, still getting an error but now it says " Startup Lua Failed". Attached is the part of the log I think is relevant..
« Last Edit: January 29, 2016, 11:25:27 pm by bigeazy000 »

Offline cybrmage

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +105/-5
Re: Eco Plugs
« Reply #8 on: January 30, 2016, 03:06:28 am »
Your log should that the code loaded without error.

The "Startup Lua failed" error message means that you have add/changed/removed something from the startup code, and is not related to the device implementation.


EVL3Vista - Wink Connect - Caseta Connect - Venstar Colortouch - WiFi UDP Switch Controller - Broadlink RM - MyQGateway

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Re: Eco Plugs
« Reply #9 on: January 30, 2016, 10:34:24 am »
Thanks for continuing to help with this. I deleted the device and recreated from scratch, this time I called it "Kitchen2" When I reload, I still see the same error, here is what it looks like in the logs:

XXX-UpdateSystemMessagesTasks now 2=Kitchen2[114]: Startup Lua Failed timeout 0 (-1454167578) count: 21pend:(null)/err:Startup Lua Failed/done:(null) <0x2b3e0680>

I'v also attached a screenshot showing my config (you can also see the error at the top). When I click the switch, nothing happens although sometimes I think it flashes "command field" very quickly. I've also confirmed the IP address in the config is correct. You can't see the full "device type" in the screenshot, but it is definitely set to "urn:schemas-upnp-org:device:BinaryLight:1"

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Re: Eco Plugs
« Reply #10 on: January 30, 2016, 10:48:38 am »
Below are some more log entries that I think are relevant:

untitled text:4149: 10   01/30/16 8:43:53.126   XXX-UpdateSystemMessagesTasks now 2=Kitchen2[114]: Startup Lua Failed timeout 0 (-1454168633) count: 22pend:(null)/err:Startup Lua Failed/done:(null) <0x2bb5c680>
untitled text:5007: 12   01/30/16 8:44:06.200   luvd_get_info_data_request starting /data_request?id=lu_action&output_format=json&DeviceNum=114&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&rand=0.4739158684387803 pMem 0x14d6000/21848064 diff: 13930496 <0x312a5680>
untitled text:5010: 08   01/30/16 8:44:06.202   JobHandler_LuaUPnP::HandleActionRequest device: 114 service: urn:upnp-org:serviceId:SwitchPower1 action: SetTarget <0x312a5680>
untitled text:5011: 08   01/30/16 8:44:06.203   JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=114 <0x312a5680>
untitled text:5016: 02   01/30/16 8:44:06.206   Device_LuaUPnP::HandleActionRequest 114 not ready 0x969de0 <0x312a5680>
untitled text:5017: 02   01/30/16 8:44:06.206   JobHandler_LuaUPnP::RunAction device 114 action urn:upnp-org:serviceId:SwitchPower1/SetTarget failed with -911/Device not ready <0x312a5680>

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Re: Eco Plugs
« Reply #11 on: January 30, 2016, 12:18:56 pm »
And more log entries, this may be the most telling:

01   01/30/16 10:10:07.316   LuaInterface::CallFunction_Startup-1 device 114 function init failed [string "..."]:151: attempt to concatenate global 'ipaddr' (a nil value) <0x2bfe4680>
01   01/30/16 10:10:07.317   LuImplementation::StartLua running startup code for 114 I_ECO_Switch.xml failed <0x2bfe4680>

Offline cybrmage

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +105/-5
Re: Eco Plugs
« Reply #12 on: January 30, 2016, 01:47:37 pm »
Typos are the bane of my existence 8-}

Try this...


** Faulty attachment removed **
« Last Edit: January 30, 2016, 04:58:26 pm by cybrmage »
EVL3Vista - Wink Connect - Caseta Connect - Venstar Colortouch - WiFi UDP Switch Controller - Broadlink RM - MyQGateway

Offline bigeazy000

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +1/-0
Re: Eco Plugs
« Reply #13 on: January 30, 2016, 02:51:59 pm »
 ;D

Getting closer, still getting "startup Lua failed". I deleted the old XML, readdded, and created a new device from scratch called "Kitchen3" Here are the logs:

50   01/30/16 12:48:56.493   luup_log:115: SengLED: Port not specified,  assumed. <0x2b556680>
01   01/30/16 12:48:56.502   LuaInterface::CallFunction_Startup-1 device 115 function init failed [string "..."]:94: bad argument #2 to 'sendto' (string expected, got table) <0x2b556680>
01   01/30/16 12:48:56.503   LuImplementation::StartLua running startup code for 115 I_ECO_Switch.xml failed <0x2b556680>

Offline cybrmage

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +105/-5
Re: Eco Plugs
« Reply #14 on: January 30, 2016, 04:57:25 pm »
Try this...



** REMOVED NON-FUNCTIONAL VERSION **
« Last Edit: January 31, 2016, 07:36:56 pm by cybrmage »
EVL3Vista - Wink Connect - Caseta Connect - Venstar Colortouch - WiFi UDP Switch Controller - Broadlink RM - MyQGateway