I just got into SmartThings and adding solar power generation to my dashboard would be great. My system is monitored by an eGauge system and they do have an API documented at https://www.egauge.net/docs/egauge-xml-api.pdf. I have retrieved data from the eGauge using URI, but I have no idea what to do with it. If any of the developers here would like to take a shot at this or get me started with some sample code, I would really appreciate it. All I really care about is for the live Solar generation value and Grid usage in kW. I ran http://egauge15753.egaug.es/cgi-bin/egauge?noteam and got data back. If you want to see eGauges built-in monitoring just remove the /cgi… part from the hyperlink. I just need help figuring out how to use the data in SmartThings. The data I need comes back as:
Under Grid, a negative value for power indicates that I am putting energy back on the Grid. That could be used to change the color of the tile, i.e. green if the value is negative, red if the value is positive. Under Solar, power divided by 1,000 will give me a live reading in kW. The tile could be green and showing the solar power if solar energy is being put back on the grid, and the tile could be red and showing the Grid power value if that value is positive; meaning I am using energy from the grid.
First… um. You might want some security on that URL. Maybe not - dunno, guess there’s nothing bad anyone can do with that.
Second, looks like this would be an external web site integration type app, and the device type you’re creating is a “sensor” - it looks likely that you could base it on some templates around power-monitoring devices.
Third, the data is plain old XML. Groovy should be able to parse XML with ease.
No problem. My system has security which is why the code has preferences for dev id and key for access but yours being open should be even easier.
My system returns json for example
Understood about learning language from docs but I can tell you I have never programmed in groovy either. But I am a current java developer so that helps a great deal. The 20year gap may make things a little more difficult
If the processing isn’t done for you perhaps you can use this to convert from XML to json
I dont’ know if JSONObject is available in ST ide. You can’t import new packages into the ide, you get what they provide you only.
Perhaps someone else can explain if ST can handle XML results.
Your system has some cool features reporting Car, AC, and Grid. I like that. Mine only monitors the PV itself.
On the other hand many of the values I had in my system yours does not report. Yours reports current power which I coded for you in my example code.
However your “power” reading is a total since last reading in terms of “hours” not really sure what that means So I am not sure if you can calculate totals I have in my original code. My system reports totals, percentages of overall system potential etc. You will have to calculate them yourself. For example you know what the max power of your system should be so you could hard code the “Production” as power/knownMaxPower. Then my Production and Max Production tiles would start working.
Today and Live Tiles are more difficult because you need to store the data somehow. Since your system doesn’t seem to report power generated totals you may just need to remove these tiles.
The last tile I have is my system ID with the text “Powered by Enphase” which is a terms requirement to use the Enlighten API. You have to label your app with the powered by enphase logo or text. You can remove this tile as well or change the text to eGauge
Thanks again. I will play with it tonight. The eGauge monitor can have 12 or 16 current sensors. It only came with sensors for the grid and for the solar panels. I added a sensor for my car charger and another for the AC. I could add more, like one for the oven and one for the dryer. The unit saves all the data in registers and they could be parsed with their API, but I will start small using the example you gave me. If I learn Groovy, I will definitely get fancier with the data.
I just finished hacking away using your code as an example. I am using two tiles to show current solar energy and current grid status in watts. The solar tile is green when solar energy is being generated. When no energy is being generated the tile is black (need to test this tonight). The grid (my power meter) tile shows negative or positive wattage. When the value is negative is means I am putting surplus energy on the grid, so the tile is green. When the value is positive it means I am using energy from the grid, so the tile changes to red. I also changed the preferences section in the code so the URL for the eGauge system is not hard coded and can be customized. Now I need to learn how to poll every X seconds so the tiles refresh automatically.