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.
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
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.
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$
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.
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.
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.
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
for meter schedule if current date > any date in the settings file it will rollover by default on the 1st of the month
To remove solar- in the device handler just go to the line 328 and from the details section just remove all the togrid_ tiles
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.
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.
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
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
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.