Rainforest Eagle to Emoncms

I was originally introduced to emoncms with my openevse. I already had a rainforest eagle collecting data from my home energy use, but didn’t know how to get the data up to the emoncms cloud to log.

Luckily, someone wrote a python module (GitHub - rainforestautomation/Eagle-Http-API: Libraries for accessing Rainforest Automation's Eagle hardware) to interface with the rainforest-eagle API. UNfortunately, I don’t know how to write a script to save my life.

I paid a fellow on guru dot com to write my python script and now I have data from my rainforest-eagle monitor writing up to the emoncms cloud.

The necessary links are provided above and here is the script:

import getopt
import sys
from eagle_http import *
import urllib

usage = r'''
    rainforest_emon.py - Get data from rainforest and post it to emoncms.org

    rainforest_emon.py [OPTIONS]

        Print verbose information.
        Rainforest username
        Rainforest password
        Rainforest cloud id
        emoncms.org api key


verbose    = 0
rainforest = {}
emonkey    = ''

def parseargs():
        global verbose
        global rainforest
        global emonkey

                opts, configfiles = getopt.gnu_getopt(sys.argv[1:], 'hv', ['help', 'verbose', 'rf-user=', 'rf-pass=', 'rf-clid=', 'emon-key='])
        except getopt.GetoptError as err:
                print str(err)
                print usage
        for o, a in opts:
                if o in ('-h', '--help'):
                elif o in ('-v', '--verbose'):
                        verbose = verbose + 1
                elif o in ('--rf-user', '--rf-pass', '--rf-clid'):
                        rainforest[o[5:]] = a
                elif o == '--emon-key':
                        emonkey = a
                        print 'Invalid option: %s' % (o)

if __name__ == '__main__':


        if not all (p in rainforest for p in ('user', 'pass', 'clid')) or emonkey == '':
                print usage

        if verbose > 0:
                print 'Retrieving values from rainforest'

        eagle = eagle_http(rainforest['user'], rainforest['pass'], rainforest['clid'])

        demand      = int(eagle.InstantaneousDemand.Demand, 0)
        if demand & 0x10000:
                demand = -((demand ^ 0xffffffff) + 1)
        multiplier  = int(eagle.InstantaneousDemand.Multiplier, 0)
        divisor     = int(eagle.InstantaneousDemand.Divisor, 0)
        timestamp   = int(eagle.InstantaneousDemand.TimeStamp, 0)
        calc_demand = (0.0 + demand) * multiplier / divisor

        if verbose > 0:
                print 'Demand: %d' % (demand)
                print 'Multiplier: %d' % (multiplier)
                print 'Divisor: %d' % (divisor)
                print 'Timestamp: %d' % (timestamp)
                print 'Calc_demand: %f\n' % (calc_demand)

        f = urllib.urlopen('https://emoncms.org/input/post.json?node=RainforestEagle&csv="Calculated Demand":%f,"Raw TimeStamp":%d,"Raw Demand":%d,"Raw Multiplier":%d,"Raw Divisor":%d&apikey=%s' % (calc_demand, timestamp, demand, multiplier, divisor, emonkey))

        if verbose > 0:
                print f.geturl(), '\n'

        if f.getcode() == 200:
                if verbose > 0:
                        print f.read()
                print "%s returned code %s:" % (f.geturl(), f.getcode())
                print f.read()
1 Like

Nice, I’ve not heard of Rainforest Eagle (cool name!)

Is this the unit?


That is the one. Its had its ups and downs, I purchased it a couple of years ago, but its been pretty stable since they moved to cloud based storage about a year or so ago.

I have the same device but an older version purchased in June 2016. Mine is the RFA-Z109.

I set it up with the Node-RED flow Rainforest Eagle Smart Meter API by Mike Thompson. As Bobby said it has its up & downs. The Rainforest Eagle data is stored on an emonPi.

Node-Red…not sure where I’ve been that I hadn’t found out about Node-Red until your post.

What a powerful tool. I already put up an MQTT server with a Smartthings bridge and realized I can pull ALL KINDS of data in, manipulate it and push it up to emoncms.

I’ve been node-red’ing for the last two days…

1 Like

That’s almost exactly what I do also! (I don’t have smartThings). I grab the local weather, my ecobee thermostat, and my Rainforest Eagle and others with Node-RED. Have fun!

Hello Bobby… what did you use to send Smartthings data to the MQTT Broker? I am looking for something to send to a Broker when something is switched on/off in my Smartthings, to read it in my Emoncms. Thanks.