Rainforest Automation Eagle ZigBee Smart Meter HAN Gateway Plugin

There are 2 conditions where the startup can fail.

if ((HAN_MACID or "") == "") then return false, "Please enter the DeviceMACID of your HAN device", "SmartMeterHAN1" end if (HAN_IP:match("%d+%.%d+%.%d+%.%d+") == nil) then return false, "Please enter the IP address of of your HAN device", "SmartMeterHAN1" end
Do you see either of these messages in the log file? And do you have the DeviceMACID variable set (case sensitive)? It will not auto-detect as the prior XML did. “HAN_MACID” is the internal variable - “DeviceMACID” is the variable you need to set on the plugin.

Back again. I’m really keen to get this plugin working but cannot.

I keep getting the message “Rainforrest Eagle[18]: Startup Lua Failed”

If I look at the log using http://[IP address]/cgi-bin/cmh/log.sh?Device=LuaUPnP i see the following message:

luup_log:18: Starting ZigBee HAN device, version 0.41js <0x2be5d680>
LuaInterface::CallFunction_Startup-1 device 18 function startup failed /usr/lib/lua/socket/http.lua:116: bad argument #2 to ‘connect’ (number expected, got string) <0x2be5d680>
LuImplementation::StartLua running startup code for 18 I_SmartMeterHAN1.xml failed <0x2be5d680>

Elsewhere I see repeats of the following message:
luup_log:18: SmartMeterHAN1: Cannot receive data from HAN device: closed <0x2c213680>
Device_Variable::m_szValue_set device: 18 service: urn:micasaverde-com:serviceId:HaDevice1 variable: CommFailure was: 1 now: 1 #hooks: 0 upnp: 0 skip: 0 v:0xee7b78/NONE duplicate:1 <0x2c213680>
Device_Variable::m_szValue_set device: 18 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: Watts was: 0 now: 0 #hooks: 0 upnp: 0 skip: 0 v:0xb6b2d8/NONE duplicate:1 <0x2c213680>
Device_Variable::m_szValue_set device: 18 service: urn:smartmeter-han:serviceId:SmartMeterHAN1 variable: LinkStrength was: 0 now: 0 #hooks: 0 upnp: 0 skip: 0 v:0xf4c728/NONE duplicate:1 <0x2c213680>
Device_Variable::m_szValue_set device: 18 service: urn:smartmeter-han:serviceId:SmartMeterHAN1 variable: LinkStatus was: ? now: ? #hooks: 1 upnp: 0 skip: 0 v:0xf4c920/NONE duplicate:1 <0x2c213680>

If I look at the device’s '‘advanced’ tab the IP address, DeviceMACID, CloudId and DeviceIN all appear to be set properly. I’ve tried DeviceMACID with and without the leading ‘0x’.

Any idea what’s going wrong?

I’ve solved the above issue. I must have had a hidden character in the DeviceIN field in the ‘advanced’ tab. I re-entered the number again and the “startup lua failed” error disappeared.

However, I’m now getting a “Cant Detect Device” error and the log contains the following:

401 11/06/17 22:44:33.490 luup_log:18: Error connecting to Rainforest Eagle server port: <0x2bcab680>

A port 80/5002 problem i assume?

I realize I have an error in the logging, so I’ve attached another implementation file which should allow us to see the error code. However, I can tell that you are not getting a ‘200’ response to the http call. What is your ‘CouldId’ set to? No special characters in there? It should be 6 hex digits, no leading 0x, just 6 characters.

It’s working! After a few restarts and carefully re-entering the cloudID and other parameters a few times, it suddenly started working. All good so far. Thanks for the plugn and your guidance getting it up and running.

Will this work with the newer Eagle-200? Amazon no longer sells the Eagle.

I suspect it will work with the Eagle-200, but I have no way to test. You could email and ask if the API is the same or similar. They know that many people use the existing API’s and would like to use code that is already out there. Hopefully they took that into consideration.

I installed the plugin, but its not working. I get this message in the log “SmartMeterHAN1 : HAN device not found. Verify connection and IP address.” and the status message on the device says “Lua Startup Failure”. I’m sure the ip address is correct. Here is the API info from their website which has it for the Eagle-200: Developer Resources - Intelligent Energy Management | Rainforest Automation

You are trying the files in the original post? If so, it may be that the XML response at port 5002 is now disabled. Try the files I have attached at this post instead: http://forum.micasaverde.com/index.php/topic,14767.msg325432.html#msg325432

I do recommend that you pick up the later implementation file from this post as well: http://forum.micasaverde.com/index.php/topic,14767.msg325466.html#msg325466

The latter makes it easier to install. Upload the files, restart Vera, set the IP and MAC address (and the cloud ID and Device IN if you have security turned on) and restart again. This uses port 80 - I think that has a better chance of working for the newer model.

I used the files you recommended. I also ended up deleting and recreating the device. I no longer get the same error of the device not found or startup error, but do see a comm failure and of course not data. Here are some of the log entries that look relevant:

01 11/14/17 2:56:52.882 Device_LuaUPnP::CreateService can’t parse xml /etc/cmh-ludl//S_SmartMeterHAN1.xml for 118/Eagle200 <0x2b29f000>
01 11/14/17 2:56:52.883 Device_LuaUPnP::CreateServices removing incomplete service from 118 <0x2b29f000>
03 11/14/17 2:57:01.893 luup_log:118: Starting ZigBee HAN device, version 0.41js LEAK this:192512 start:458752 to 0xde8000 <0x2bbd3680>
02 11/14/17 2:57:02.100 ZWaveJobHandler::SetDeviceStatus XXX2 0/0/0/0 LEAK this:77824 start:536576 to 0xdfb000 <0x2b9d3680>
01 11/14/17 2:57:02.248 luup_require can’t find dkjson <0x2bbd3680>
06 11/14/17 2:57:02.309 Device_Variable::m_szValue_set device: 118 service: urn:micasaverde-com:serviceId:HaDevice1 variable: CommFailure was: 1 now: 1 #hooks: 0 upnp: 0 v:0xa82490/NONE duplicate:1 <0x2bbd3680>
03 11/14/17 2:57:02.310 luup_log:118: Starting ZigBee HAN device, version 0.41js <0x2bbd3680>
02 11/14/17 2:57:02.312 luup_require duplicate dkjson <0x2bbd3680>
06 11/14/17 2:57:02.358 Device_Variable::m_szValue_set device: 118 service: urn:micasaverde-com:serviceId:HaDevice1 variable: CommFailure was: 1 now: 1 #hooks: 0 upnp: 0 v:0xa82490/NONE duplicate:1 <0x2bbd3680>

Let’s start with the 2 issues:

  1. you are missing dkjson. You can download it from here dkjson - dkjson and upload it to your Vera.

  2. something is wrong with S_SmartMeterHAN1.xml - did it get uploaded correctly to your Vera or corrupted somehow? Try uploading again.

After fixing both of the above, try a reboot.

I uploaded the dkjson file and reuploaded S_SmartMeterHAN1.xml and those errors are gone from the logs. I still see the comm failure however:

03 11/18/17 5:05:01.554 luup_log:118: Starting ZigBee HAN device, version 0.41js <0x2bcdf680>
01 11/18/17 5:05:01.846 luup_require can’t find lpeg <0x2bcdf680>
06 11/18/17 5:05:01.883 Device_Variable::m_szValue_set device: 118 service: urn:micasaverde-com:serviceId:HaDevice1 variable: CommFailure was: 1 now: 1 #hooks: 0 upnp: 0 v:0x8826c8/NONE duplicate:1 <0x2bcdf680>

I am getting output to the rainforest cloud.

2 suggestions:

  1. go back to this post (http://forum.micasaverde.com/index.php/topic,14767.msg325432.html#msg325432) and download the implementation file that I just uploaded. I fixed the logging so we should be better able to see what is going wrong. Upload the file and reload and take a look at the log.

  2. type this into your browser (replace the IP with your Eagle’s IP): http://192.168.1.201/cgi-bin/cgi_manager Does it ask for authentication? If so, type in the CloudId and DeviceIN you put into the plugin. In either case, what do you see if you do this? Something like “{}” would be normal. Maybe you have an error message?

I did both those things. Following item#2, I was prompted to authenticate then got “404 - Not Found”. I don’t know what interfaces the original Eagle has, but when going to the host on port 80 with the Eagle 200, the only thing you can do is set up the wifi. No other configuration settings are available.

I restarted Vera and the Eagle 200 for good measure. Here are the logs with the new implementation file:
09 11/18/17 12:40:15.534 JobHandler_LuaUPnP::Run device 118 Eagle200 room 0 type urn:schemas-smartmeter-han:device:SmartMeterHAN1:1 id parent 0/0xcf6148 upnp: 0 <0x2ab21000>
03 11/18/17 12:40:19.126 luup_log:118: Starting ZigBee HAN device, version 0.41js <0x2b455680>
06 11/18/17 12:40:19.355 Device_Variable::m_szValue_set device: 118 service: urn:micasaverde-com:serviceId:HaDevice1 variable: CommFailure was: 1 now: 1 #hooks: 0 upnp: 0 v:0xd0e860/NONE duplicate:1 <0x2b455680>
03 11/18/17 12:40:19.356 luup_log:118: Starting ZigBee HAN device, version 0.41js <0x2b455680>
02 11/18/17 12:40:19.358 luup_require duplicate dkjson <0x2b455680>
06 11/18/17 12:40:19.365 Device_Variable::m_szValue_set device: 118 service: urn:micasaverde-com:serviceId:HaDevice1 variable: CommFailure was: 1 now: 1 #hooks: 0 upnp: 0 v:0xd0e860/NONE duplicate:1 <0x2b455680>

Hmm, pretty sure you didn’t get the latest I uploaded because it should have said 0.44js. But that’s irrelevant if you can’t get anything on port 80. There’s no local access? On mine I can get to the interface that you can see in the snippet I attached (just the IP address, no cgi added to it in the URL). If you can get there, use Chrome and hit F12 to see what it is doing. I looked at the network tab and can see the cgi-bin/cgi_manager calls. I have to believe that there is something similar in the 200. Take a look and see what you find.

I don’t have a device home page that looks like yours. Actually there is discussion elsewhere like Amazon reviews about the lack of a local interface for the Eagle 200. I think they released it before everything was built. It doesn’t work with the EnergyVUE mobile app either, but they are supposed to come out with a new app in Q1 2018. I attached an image of my home screen.

You were correct on the implementation file. I did something wrong. Fixed and here is the output:
09 11/18/17 13:41:13.974 JobHandler_LuaUPnP::Run device 118 Eagle200 room 0 type urn:schemas-smartmeter-han:device:SmartMeterHAN1:1 id parent 0/0xc99070 upnp: 0 <0x2ab36000>
03 11/18/17 13:41:16.617 luup_log:118: Starting ZigBee HAN device, version 0.44js <0x2b269680>
01 11/18/17 13:41:16.937 luup_require can’t find lpeg <0x2b269680>
01 11/18/17 13:41:16.949 luup_log:118: Error connecting to Rainforest Eagle server port: 404 <0x2b269680>
06 11/18/17 13:41:16.950 Device_Variable::m_szValue_set device: 118 service: urn:micasaverde-com:serviceId:HaDevice1 variable: CommFailure was: 1 now: 1 #hooks: 0 upnp: 0 v:0xcb17b0/NONE duplicate:1 <0x2b269680>

I suppose that the plugin could try to fetch the data from the Rainforest servers. Kind of goofy since it has the data locally, sends it out, then the plugin pulls it back from the cloud. I’d have to think about that a bit. There is an API for it, but it’s definitely more complicated than the local access.

According the developer guide for the 200 it appears that there is a post manager. Can you try accessing this (with your correct IP)? http://192.168.1.201/cgi-bin/post_manager

You may not get anything back, but you are hoping to see no error. If that works, then I think it is possible to access the data locally. Unfortunately it appears to only support XML, not JSON, so I’d have to make a hybrid of the original code that parses XML. If you are familiar with curl you can try doing some post requests and see if you can get responses. In any case, see what you get with the URL above.

Doing http://192.168.3.210/cgi-bin/post_manager gives a blank page - no error. I don’t know curl, but can learn. Are there a few curl post requests I should try?

You would want to try something like this with curl:

curl --trace trace -X POST -i -H “Content-Type: text/xml” -u ‘user:password’ --data-binary ‘wifi_status’ http://192.168.1.201/cgi-bin/post_manager

–trace trace puts the log information into the file named trace, -X POST makes it a post request, -H sets the content type, -i includes the HTTP response headers in the output

You need to figure out the user name and password. The developer guide says the user name is the Cloud ID, and the password is the “EAGLE install code”. Not sure what that is, but maybe you do?

–data-binary gives the command we want, and it ends with the http URL - change the IP. Also note that this is all one line.

This would be easier with direct access, but you’ll likely need to fiddle with this a bit to get it to work. Look into the ‘trace’ file each time you try to get some debug information. If it does work, you should see some XML come back that indicates the WiFi status. If you get that far, there is a good chance to make it work.

The next step would be to try this as the command instead of the one above: ‘device_list’

The CloudID and Install Code are both printed on the sticker that comes with the Eagle 200 device. I used those with the curl commands you sent and it all works perfectly. It also is in the log file, but here was the XML on screen:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: http://homebase.rainforestautomation.com:8080
Access-Control-Allow-Headers: Authorization, Content-Type, Accept
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 86400
Content-type: text/html
Transfer-Encoding: chunked
Date: Sun, 19 Nov 2017 16:31:08 GMT
Server: lighttpd/1.4.32

0x00078100006a18d7 Generic electric_meter Zigbee 0x5a11b1cb Connected 0x0000