[OBSOLETE] 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 (RAVEN USB ADAPTER IS NOW ZIGBEE SMART ENERGY CERTIFIED - Intelligent Energy Management | Rainforest Automation).

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

  1. GitHub - stjohnjohnson/smartthings-mqtt-bridge: Bridge between SmartThings and MQTT - 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

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.

The old smartthings app is finally deadā€¦ which means we no longer have all the usefull calculated data we had with the custom DHā€¦ and I havenā€™t seen a way to get them working on the new app.

Any possibility or thatā€™s that?

Officially dead?