Haiku Rainforest EAGLE energy gateway integration

neillt

Active Member
Lupinglade,
 
Here is a feature request for you... all 3 of California's energy utilities (PG&E, SDG&E, and SoCal Ed) have rolled out large installs of Smart Meters (everyone I know here in San Diego has one now)... and all 3 utilities have approved the Rainforest Automation EAGLE as a Zigbee device that translates energy information into an XML/REST interface that can be queried via IP, as well as being able to make HTTP POST calls to a URL of your choosing.  They also make a USB device called a RAVEn that does the same thing but provides the XML over a USB serial device on a single host.
 
Their developer page is here:  http://www.rainforestautomation.com/developer
 
Would it be possible to add the integration of these devices into the roadmap for HaikuHelper?  It looks like it provides at least as much information as the TED 5000 does, and could also be used for setting energy cost on the Omni, since the EAGLE will report which billing tier your house is currently in.  It would allow at least anyone in California (and possibly elsewhere) to finally get a connection to the Electric Utility to make decisions based on demand and cost... as well as send alerts to let people know they have busted into a higher pricing tier due to their usage.
 
 
 
This should actually be very easy to add via scripting already. You can request the XML using XMLHTTPRequest and then just get the info you need and use controller.SendEnergyCost(x);
 
Is that all the TED 5000 integration gets you?  The EAGLE also gives energy usage, current billing rate per kw/h, etc.  Maybe in the future it could be logged like how the climate controls are now with nice pretty graphs?
 
This is obviously all "nice to haves", not "break/fix" type priorities.
 
To resurrect this from the dead, this was my project for the morning.  The EAGLE doesn't take in HTTP POST or GET requests, you have to connect to a socket, upload the command you want in a fragment XML format, and then read the result.
 
Here is an example of this exchange that I did manually via a raw socket session in the terminal... the "LocalCommand" block is what I sent to the EAGLE, the rest is the response.
 

<LocalCommand>
<Name>get_device_data</Name>
<MacId>0xd8d5b90000000d1b</MacId>
</LocalCommand>

<NetworkInfo>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<Status>Connected</Status>
<MeterMacId>0x00078100007ef15c</MeterMacId>
<ExtPanId>0x7fffffffffffffff</ExtPanId>
<ShortAddr>0x0000ffff</ShortAddr>
<Channel>11</Channel>
<LinkStrength>100</LinkStrength>
</NetworkInfo>
<DeviceInfo>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<InstallCode>0x2106382813d3607a</InstallCode>
<LinkKeyHigh>a8710899d02752c0</LinkKeyHigh>
<LinkKeyLow>1c19d104ff5baa2b</LinkKeyLow>
<FWVersion>1.4.27 (5278)</FWVersion>
<HWVersion>3.2.3</HWVersion>
<Manufacturer>Rainforest Automation, I</Manufacturer>
<ModelId>RFA-Z109 EAGLE</ModelId>
<DateCode>20121201EC051052</DateCode>
</DeviceInfo>
<InstantaneousDemand>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<MeterMacId>0x00078100007ef15c</MeterMacId>
<Demand>0x000001eb</Demand>
<TimeStamp>0x19aba897</TimeStamp>
<Multiplier>0x00000001</Multiplier>
<Divisor>0x000003e8</Divisor>
<DigitsRight>0x00000003</DigitsRight>
<DigitsLeft>0x00000006</DigitsLeft>
<SuppressLeadingZero>0x0001</SuppressLeadingZero>
</InstantaneousDemand>
<CurrentSummation>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<MeterMacId>0x00078100007ef15c</MeterMacId>
<SummationDelivered>0x000000000048aca6</SummationDelivered>
<SummationReceived>0x0000000000000000</SummationReceived>
<Multiplier>0x00000001</Multiplier>
<Divisor>0x000003e8</Divisor>
<DigitsRight>0x00000003</DigitsRight>
<DigitsLeft>0x00000006</DigitsLeft>
<SuppressLeadingZero>0x01</SuppressLeadingZero>
</CurrentSummation>
<PriceCluster>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<MeterMacId>0x00078100007ef15c</MeterMacId>
<Price>0xffffffff</Price>
<Currency>0xffff</Currency>
<TrailingDigits>0xff</TrailingDigits>
<Tier></Tier>
<RateLabel></RateLabel>
</PriceCluster>
<MessageCluster>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<MeterMacId>0x00078100007ef15c</MeterMacId>
<Id>0x0000</Id>
<Text></Text>
<ConfirmationRequired>N</ConfirmationRequired>
<Confirmed>N</Confirmed>
<Queue>active</Queue>
</MessageCluster>
<MeterInfo>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<MeterMacId>0x00078100007ef15c</MeterMacId>
<Type>0x0000</Type>
<Nickname></Nickname>
<Account></Account>
<Auth></Auth>
<Host></Host>
<Enabled>0x00</Enabled>
</MeterInfo>


 
So, I know I can query the EAGLE manually and get all of the info I want as a nice XML package.  So, I figured I can trigger HaikuHelper to perform the same thing over a Sockets interface, triggered by a Button on the OmniProII.  This is the code I have in HaikuHelper:
 

var eagle_mac = "0xd8d5b90000000d1b";
var eagle_ip = "192.168.1.22";
var eaglereturn ="";

function onButtonActivate(button){
if (button.number == 1) {
helper.sendNotification (controller,"This is a test push!");
}
if (button.number == 2) {
helper.log (controller,"Button #2 was seen.");
helper.log (controller,"Going to initialize EAGLE socket now.");
var socket = helper.openSocket(controller, eagle_ip,5002);
var request = "<LocalCommand>\r <Name>get_device_data</Name>\r <MacId>" + eagle_mac + "</MacId>\r </LocalCommand>\r";
helper.log (controller,"Going to send the following text " + request);
helper.log (controller,"Sending to EAGLE now.");
socket.write(request);
}
if (button.number == 3) {
helper.log (controller,"Button #3 was seen.");
helper.log (controller,"Total result from EAGLE is:\r"+eaglereturn);
eaglereturn="";
}
}

function onSocketBytesAvailable(socket) {
helper.log(controller,"Notified of return EAGLE data.");
var tempresult = socket.read();
helper.log (controller,"Data returned was\r" + tempresult);
if (tempresult != null) {
helper.log (controller,"Adding to cumulative results");
eaglereturn = eaglereturn + tempresult;
}
else {
helper.log (controller,"Undefined result returned");
}
}

 
So, I press button 2 to kick off the EAGLE query.  The request is properly formed, the socket is opened, and the request is sent.  However the reply is not getting through.  I do a button 3 push as well to show the final result. Here is the log from the exchange:
 

Aug 24 10:28:37 mac-mini.neillt.com HaikuHelper[44415] <Info>: Lakeside: Initializing scripting environment…
Aug 24 10:28:37 mac-mini.neillt.com HaikuHelper[44415] <Info>: Lakeside: Applying controller script…
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Button #2 was seen.
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Going to initialize EAGLE socket now.
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Going to send the following text <LocalCommand>
<Name>get_device_data</Name>
<MacId>0xd8d5b90000000d1b</MacId>
</LocalCommand>

Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Sending to EAGLE now.
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Notified of return EAGLE data.
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Data returned was
undefined
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Undefined result returned
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Notified of return EAGLE data.
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Data returned was
undefined
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Undefined result returned
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Notified of return EAGLE data.
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Data returned was
undefined
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Undefined result returned
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Notified of return EAGLE data.
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Data returned was
undefined
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Undefined result returned
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Notified of return EAGLE data.
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Data returned was
<Id>0x0000</Id>
<Text></Text>
<ConfirmationRequired>N</ConfirmationRequired>
<Confirmed>N</Confirmed>
<Queue>active</Queue>
</MessageCluster>
<MeterInfo>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<MeterMacId>0x00078100007ef15c</MeterMacId>
<Type>0x0000</Type>
<Nickname></Nickname>
<Account></Account>
<Auth></Auth>
<Host></Host>
<Enabled>0x00</Enabled>
</MeterInfo>
Aug 24 10:28:42 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Adding to cumulative results
Aug 24 10:28:44 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Notified of return EAGLE data.
Aug 24 10:28:44 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Data returned was
undefined
Aug 24 10:28:44 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Undefined result returned
Aug 24 10:28:52 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Button #3 was seen.
Aug 24 10:28:52 mac-mini.neillt.com HaikuHelper[44415] <Notice>: Lakeside: Script output: Total result from EAGLE is:
<Id>0x0000</Id>
<Text></Text>
<ConfirmationRequired>N</ConfirmationRequired>
<Confirmed>N</Confirmed>
<Queue>active</Queue>
</MessageCluster>
<MeterInfo>
<DeviceMacId>0xd8d5b90000000d1b</DeviceMacId>
<MeterMacId>0x00078100007ef15c</MeterMacId>
<Type>0x0000</Type>
<Nickname></Nickname>
<Account></Account>
<Auth></Auth>
<Host></Host>
<Enabled>0x00</Enabled>
</MeterInfo>


So it seems that the first few blocks of data are getting lost somewhere, and all I am getting is the last chunk, which isn't particularly useful. 
 
Am I making a basic mistake here?  It looks like the flow is right, we just aren't capturing all of the data.
 
Help is greatly appreciated!
 
I think there may be a bug in HH here. Can you send me your e-mail address via PM and I will send you a test build to see if it will work better. Thanks!
 
OK... just upgraded to HH 4.1, and now when my EAGLE Poll Script runs (which was working fine on HH 3.x) it beach balls and i have to force quit.
 
I don't even see the first command executed, which is to say the button was seen and to execute the script.
 
I don't even know how to troubleshoot this.
 
First, hold shift when HaikuHelper starts to ensure the script isn't executed on start. Then you can debug the script as usual.

Can you run a profile on it when it beach balls using Activity Monitor and send it to me?

PS. perhaps the network connection is hanging?

Also I don't think you are going about it the right way using the socket functionality? You can simply use XMLHttpRequest(), it would work a lot better I think and be easier to work with. If I understand what you are doing correctly.
 
lupinglade said:
First, hold shift when HaikuHelper starts to ensure the script isn't executed on start. Then you can debug the script as usual.

Can you run a profile on it when it beach balls using Activity Monitor and send it to me?

PS. perhaps the network connection is hanging?

Also I don't think you are going about it the right way using the socket functionality? You can simply use XMLHttpRequest(), it would work a lot better I think and be easier to work with. If I understand what you are doing correctly.
 
I could re-do the code... it's just strange it worked before and now it hangs.
 
I should have clarified that it doesn't beach ball until it sees the button that fires the big EAGLE script.  If I don't run that, then it works just fine.
 
I'll profile it and send it over.
 
neillt, did you ever get this working?  I'm looking at the EAGLE interface myself right now and I have the same desire to integrate with my Omnipro via HH.
 
Any updates on this? I'm currently exploring various home controller systems and so far I'm leaning towards HAI (omnitouch). It would be awesome it could be accessed through the touchscreen interface.
 
All,
 
Yes I did get it functional.  I am traveling for work for the next few weeks so it will be a little bit before I can get the code uploaded.
 
Back
Top