[RELEASE] Integrating Smart Electric Meter in Texas with Smartthings using Rainforest EMU2

This is my attempt to integrate the Smart Electric Meter being used by Oncor in the Texas Area.

Besides the smartmetertexas.com website which is pretty useless there did not seem to be many options to view real time data except going to the meter.

Since I have Solar panels and there is no net metering in Texas I wanted to get real time info to smartthings to turn AC/Heater on/off when excess energy was being produced. Also there are retail energy plans which provide incentive based on usage pattern so i wanted to track exact usage for e.g to use 1000 units a month or targets like that.

The only device I found which would let me view this usage inside was EMU2 from rainforest. they also have a gateway but I couldn’t find any integration with smartthings - there might be a way to integrate with PVwatts and then to smartthings but seemed convoluted. a RAVEn RFA-Z106 dongle (http://www.rainforestautomation.com/raven).

After much research i found disparate tools to integrate together what I really wanted. Here is what you will need.

  1. https://github.com/stjohnjohnson/smartthings-mqtt-bridge - You need this bridge to transmit mqtt message to hub and back. This is our SERVER process using node.js - this you need to download from that repository and install

  2. I created node.js implementation that connects to ravenforest (raven.js) - gets the data and transmits it to the bridge (raven_mqtt.js) which relays it to smartthings. This I am calling the CLIENT (see the linux shell scripts to launch these). All configurable properties are in settings.json

  3. Smartthings Device Handler (Gupta Raven EMU2 Energy Monitor (Local) - DH.groovy) - This is the groovy script - I made major changes to stjohnjohnson’s device handler integrting bridge and smartapp into one and also added graphical capabilities from Andreas Amann to give me the view that you see in the screenshots.

I can basically see current usage, peak usage for day, usage for current billing period. Also a graph that shows usage and total consumption for today and overlays it on graph from yesterday (really nifty - thanks Amann). And the the summary table for consumption (1st column) and excess from solar to grid (2nd column) - for today, yesterday, this month, last month and lifetime.

This has been the most useful tool that I have had.
I am running all these on a 1st gen raspberry pi and i run into an issue where the serial port connection between EMU2 and the pi time out for a reason i have not been able to fathom. The script checks and restablishes connection but it is finicky - sometimes I have to reseat the USB connection and reboot the pi to have it working again. Mostly it works wihtout issues for months but having that persistent serial connection with EMU2 could be a pain. From what I remember don’t think I noticed these problems on windows.

Check it out at

TopView bottomview

4 Likes

This is exactly what I’m looking for. Also live in Texas and although the SMT website got a facelift it’s still not that useful.

Is this still working for you??

Thanks for creating this. It’s also exactly what I’m looking for.

I think I’m close to getting the node script to run, but seem to be hitting an undefined date error as below. Any thoughts?

mike@localhost:~/emu2$ ./runraven
Path specified ‘’ does not exist. Resorting to default path '/home/mike/emu2/log/ '.
Path specified ‘’ does not exist. Resorting to default path '/home/mike/emu2/data/ '.
[winston] Attempt to write logs with no transports {“message”:"{“serialPath”:"/dev/ttyACM0",“mqttHost”:“mqtt://localhost”,“mqttPort”:1883,“logLevel”:“info”,“demandPath”:“smartthings/emu2/demand”,“energyInPath”:“smartthings/emu2/energyin”,“energyOutPath”:“smartthings/emu2/energyout”,“currentUsagePath”:“smartthings/emu2/usagecurrent”,“lastUsagePath”:“smartthings/emu2/usagelast”,“mqttMsgPath”:“smartthings/emu2/mqttmsg”,“mqttErrPath”:“smartthings/emu2/mqtterr”,“msgPath”:“smartthings/emu2/msghandler”,“logFolderPath”:"",“dataFolderPath”:"",“pollDemandFreq”:“15”,“pollAllFreq”:“230”,“portResetFreq”:“1800”,“dataSaveTimer”:“900”,“meterReadSch”:“07/04/2020,07/06/2020”}",“level”:“debug”}
[winston] Attempt to write logs with no transports {“message”:“Loading saved data…”,“level”:“info”}
[winston] Attempt to write logs with no transports {“message”:“No previous state found, continuing”,“level”:“info”}
/home/mike/emu2/raven.js:282
lastmonth:{energyout:0, energyin:0, startdate:(new Date(date.today.getTime()).setMonth(data.today.getMonth()-1)), enddate:data.today, days:0}};
^

ReferenceError: date is not defined
at loadSavedData (/home/mike/emu2/raven.js:282:59)
at initialize (/home/mike/emu2/raven.js:117:14)
at new Raven (/home/mike/emu2/raven.js:97:2)
at RavenMqtt (/home/mike/emu2/raven_mqtt.js:19:15)
at Object. (/home/mike/emu2/raven_mqtt.js:118:13)
at Module._compile (module.js:652:30)
at Object.Module._extensions…js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
mike@localhost:~/emu2$

I sorted it out, I believe. The line should read new Date(data.today) instead of date.today.

Anyway, it’s running and I can see my realtime usage. Thanks so much for this project!

Do the graphs take some time to build?

Got it to work. I was missing the broker (mosquitto). Once installed it started workind… kind of.

I only have the current meter reading on my Device (in smartthings app). The graph doesn’t load (keeps spinning).

The info at the bottom for today, yesterday etc won’t load either.

Also it seems that consumption only updates when I change “pages” in smartthings… for example going to the list of devices and back to the meter device it’ll update. If I keep looking at it it won’t.

Monitoring smartthings-mqtt-bridge I noticed only smartthings/emu2/demand updates are showing… I’d expect to also see smartthings/emu2/mqttMsg but there are none.

Not sure if raven.js is not sending them or smartthings-mqtt-bridge is ignoring them.

Hopefully this project isn’t abandoned.

After a lot of time trying to understand how all of this worked I managed to find out why data wasn’t populating.

My EMU2 device is new, therefore it still doesn’t have “previous period data”.
raven.js fires the mqtt payload after reading the previous period data from the EMU, since there’s no data to deliver the mqtt msg is never sent.

What I did to solve the issue was to manually restart the period in the EMU device by going to the “total to date” page display on the meter and holding the UP button for 5 seconds. This will open a new period thus creating an previous period with whatever data you have till date.

After this the device was able to populate all the data without problem.

1 Like

Thanks for sorting that out. I was having the exact same problem but hadn’t taken the time to understand it further. I think I’ll leave my billing periods as configured inside the EMU-2, and just wait for the next period to update the SmartApp. I was concerned that my line-282 modification broke some functionality with the graph and period tiles.

If you know the exact dates your meter is read by your company you can enter those on the settings file.

That way raven.js will tell your EMU2 when to close the period and your readings will be accurate to your actual billing cycle.

If no dates are configured then raven.js will close the periods the first day of the month.

By having the correct dates set I modified the handler to calculate a dollar amount based on my month usage (which is correct for my billing cycle). Also removed everything relating to solar data as I don’t have solar panels to make space to display the data I added.

1 Like

Would you mind sharing your handler? I also don’t have solar, but don’t see it called out as a specific section. (I have near-zero experience with groovy)

Sorry guys. My development environment was victim of ransomware so I lost everything and haven’t had the time to restart everything as yet. and thats why not reviewing messages.

I am glad it is working for you folks. I did create a more robust ST-MQTT bridge but if the legacy version is working - no need to change.

FYI

  1. for meter schedule if current date > any date in the settings file it will rollover by default on the 1st of the month

  2. To remove solar- in the device handler just go to the line 328 and from the details section just remove all the togrid_ tiles

hope that helps

1 Like

Thanks for your work. It’s exactly what I was looking for so I don’t have to be manually calculating current usage on the SmartMeterTexas website.
That siste is supposed to now have better API than before but still the process to get access by filing forms and what not is kind of cumbersome. Way faster getting the data from the EMU device.

1 Like

Mike, you can try what GMFan suggested to get rid of the solar data.

I modified mine to include my provider credits (If I go within certain usage ranges I get credits on my bill at the end of the month) I’m using that info and the info on my EFL to estimate the actual monthly running cost in dollars - taxes. I plan adding taxes in the future so I can get as close to actual bill cost as possibe.

Altough the calcuations wont be accurate if you company doesn’t provide said credits I can still post mine if you still want to play with it… I just don’t know whats the best method to post it.

1 Like

Mike
one more thing - besides changing details section on lines 120,162, 200,238, and line 275 increase width from 2 to 4 otherwise tiles will be messed up

The primary thing i was doing was using electricity if solar was being sent back to grid since no net metering - using webcore setup routines.

If you have peak / off peak rates, or nights / weekend plan - you can also setup appliances using webcore to turn-on / turnoff

I’ll go through this all in detail as soon as I get a chance, but I’m heading off for three weeks vacation so it may be a bit. Thanks for all the information.

I have a simple two-tier usage based rate with two month billing cycles, so it should be fairly straight forward to iron this out.

I actually work for my own electric utility on the smart meter network, (more networking side of things) so it’s interesting to see this from both ends. We ship 15 minute interval data back across the mesh for billing, so the EMU data is vastly more granular.

Hi All! I just got an EMU-2; does anyone know whether this integration works with the new app and not the classic app? I’m still trying to learn about device handlers and apps. Thanks!

I’ve had the basic real-time readings working in the new app, but not the consumption or history tables. I would imagine this whole effort will need reworking once the Groovy IDE is retired, unfortunately

Works but it only displays energy consumption and power meter.
The other useful info + the nice graph are gone.

This is the only thing thing me to the old app.

Hopefully it isn’t too hard to port it.