mysolar diff to show exported total

I use mysolar as a general dashboard and I wanted to see how much I have exported in the period dispalyed.

I knocked together this very quick change; may or may not interest others.

File truncated when originally posted
See http://openenergymonitor.org/emon/node/12121#comment-39062 for corrected file.
Moderator - BT

Paul Reed's picture

Re: mysolar diff to show exported total

Hi Peter, have you a git url please, it would be easier to test from there.

Paul

Peter Galbavy's picture

Re: mysolar diff to show exported total

I just used whatever the instructions said for install/upgrade to 9.3.

I have made one more change as I noticed a divide by zero:

(stupid default "git diff" pipes to "less" which truncates lines on a terminal, sigh)

 

$ git diff|cat
diff --git a/mysolarpv/mysolarpv.html b/mysolarpv/mysolarpv.html
index 4716bf2..66e452e 100644
--- a/mysolarpv/mysolarpv.html
+++ b/mysolarpv/mysolarpv.html
@@ -86,7 +86,7 @@

     <style>
         .appbox {
-            width:25%;
+            width:20%;
             text-align:center;
             padding:10px;
             vertical-align:top;
@@ -124,6 +124,12 @@
             <div class="appbox-title">SOLAR</div>
             <div><span class="appbox-value" id="total_solar_kwh" style="color:#dccc1f">0</span> <span class="appbox-units" style="color:#dccc1f">kWh</span></div>
         </td>
+
+        <td class="appbox">
+            <div class="appbox-title">EXPORT</div>
+            <div style="padding-bottom:5px"><span class="appbox-value" id="total_export_prc" style="color:#dccc1f">0</span></div>
+            <div><span class="appbox-units" id="total_export_kwh" style="color:#dccc1f">0</span> <span class="appbox-units" style="color:#dccc1f">kWh</span></div>
+        </td>

         <td class="appbox">
             <div class="appbox-title">DIRECT</div>
diff --git a/mysolarpv/mysolarpv.js b/mysolarpv/mysolarpv.js
index 86d1cb5..a7d64a3 100644
--- a/mysolarpv/mysolarpv.js
+++ b/mysolarpv/mysolarpv.js
@@ -408,6 +408,11 @@ var app_mysolarpv = {
         $("#total_use_direct_kwh").html((total_use_direct_kwh).toFixed(1));
         $("#total_use_via_store_kwh").html((total_use_kwh-total_use_direct_kwh).toFixed(1));

+       $("#total_export_kwh").html((total_solar_kwh-total_use_direct_kwh).toFixed(1));
+       var solar_or_zero = 0;
+       if (total_solar_kwh>0) solar_or_zero = 1-(total_use_direct_kwh/total_solar_kwh);
+        $("#total_export_prc").html(Math.round(100*(solar_or_zero))+"%");
+
         options.xaxis.min = view.start;
         options.xaxis.max = view.end;

Peter Galbavy's picture

Re: mysolar diff to show exported total

Got it from here - https://github.com/emoncms/app

Peter

Paul Reed's picture

Re: mysolar diff to show exported total

Peter, I know where the original files are housed, I meant your repo, so I could clone it. It's much easier to test that way.

Paul

Peter Galbavy's picture

Re: mysolar diff to show exported total

I am simply editing the files on my local server after a "git clone". I am not a git user - I'm more old school with rcs/cvs - so I'm just being an "end user" on this one. I am not set-up to do any real development, I just hacked in this "feature" for my own use into a live install.

Latest diff was in the last update which in your moderation queue (divide by zero avoided) as I kept trying to format it for this slightly weird forum software.

Peter Galbavy's picture

Re: mysolar diff to show exported total

Once more, in case it got lost; latest diff inc. no divide by zero.

$ git diff|cat
diff --git a/mysolarpv/mysolarpv.html b/mysolarpv/mysolarpv.html
index 4716bf2..66e452e 100644
--- a/mysolarpv/mysolarpv.html
+++ b/mysolarpv/mysolarpv.html
@@ -86,7 +86,7 @@

     <style>
         .appbox {
-            width:25%;
+            width:20%;
             text-align:center;
             padding:10px;
             vertical-align:top;
@@ -124,6 +124,12 @@
             <div class="appbox-title">SOLAR</div>
             <div><span class="appbox-value" id="total_solar_kwh" style="color:#dccc1f">0</span> <span class="appbox-units" style="color:#dccc1f">kWh</span></div>
         </td>
+
+        <td class="appbox">
+            <div class="appbox-title">EXPORT</div>
+            <div style="padding-bottom:5px"><span class="appbox-value" id="total_export_prc" style="color:#dccc1f">0</span></div>
+            <div><span class="appbox-units" id="total_export_kwh" style="color:#dccc1f">0</span> <span class="appbox-units" style="color:#dccc1f">kWh</span></div>
+        </td>

         <td class="appbox">
             <div class="appbox-title">DIRECT</div>
diff --git a/mysolarpv/mysolarpv.js b/mysolarpv/mysolarpv.js
index 86d1cb5..a7d64a3 100644
--- a/mysolarpv/mysolarpv.js
+++ b/mysolarpv/mysolarpv.js
@@ -408,6 +408,11 @@ var app_mysolarpv = {
         $("#total_use_direct_kwh").html((total_use_direct_kwh).toFixed(1));
         $("#total_use_via_store_kwh").html((total_use_kwh-total_use_direct_kwh).toFixed(1));

+       $("#total_export_kwh").html((total_solar_kwh-total_use_direct_kwh).toFixed(1));
+       var solar_or_zero = 0;
+       if (total_solar_kwh>0) solar_or_zero = 1-(total_use_direct_kwh/total_solar_kwh);
+        $("#total_export_prc").html(Math.round(100*(solar_or_zero))+"%");
+
         options.xaxis.min = view.start;
         options.xaxis.max = view.end;

 

Edit - attached diff file - Moderator, BT

Bill Thomson's picture

Re: mysolar diff to show exported total

Hi Peter,

Lots of folks here aren't well versed with Linux and its various support apps. Perhaps posting the instructions on using patch with your diff file would help. (both patching, and reversing the patch)

Regards,

Bill

Peter Galbavy's picture

Re: mysolar diff to show exported total

Normally, just pipe the diff to "patch" in the directory concerned. Not sure that modern "patch" needs to know the depth (-pN option) of the path. e.g.

$ patch < file.diff to apply the patch

and

$ patch -R < file.diff

to reverse (remove) the patch

Although given how short the above is, edit the one changed line and paste the new lines in the right places also removing the leading "+" signs.

 

Edit - added patch reversal command - Moderator, BT

timneo's picture

Re: mysolar diff to show exported total

Ha, well I was looking for the flip side to this (the amount used from the solar, as opposed to the generated!)

I hope some features like this get used - it'd really be nice to have these added as stats.

Peter Galbavy's picture

Re: mysolar diff to show exported total

Cool! But isn't what you're looking for just the "DIRECT" bit (in green) ?

timneo's picture

Re: mysolar diff to show exported total

Ah, not yet installed your script, but yes that may do it.  I don't use mysolar (or, being new at this, haven't seen/heard what it is and whether it's a function on OEM)

Peter Galbavy's picture

Re: mysolar diff to show exported total

Ah, right. My diff above is not a script per se but applies changes to the existing app written by others. The mysolar app is a nice simple dashboard but you have to set up the feeds right. The app is on the main emoncms.org site but if you install your own you have to "git clone" the apps directory as it's been separated from the main emoncms app. I don't think it's on the EmonPi default install either, and I am not sure it would be right to run it there.

To get started, feed your data to and "play" on the emoncms.org service.

Peter Galbavy's picture

Re: mysolar diff to show exported total

I've also now changed "EXPORT" to "SURPLUS" in my own local instance.

Peter Galbavy's picture

Re: mysolar diff to show exported total

One more diff. Re-ordered the numbers and renamed DIRECT to UTILISED and EXPORT to SURPLUS. Those are just my preferences and not cast in stone.

Now I read it as "the house used this much, I generated this much of which I used so and so, importing so much from the grid and a surplus of such" Sort of.

 

$ git diff -w | cat
diff --git a/mysolarpv/mysolarpv.html b/mysolarpv/mysolarpv.html
index 4716bf2..16dcb5f 100644
--- a/mysolarpv/mysolarpv.html
+++ b/mysolarpv/mysolarpv.html
@@ -86,7 +86,7 @@

     <style>
         .appbox {
-            width:25%;
+            width:20%;
             text-align:center;
             padding:10px;
             vertical-align:top;
@@ -126,7 +126,7 @@
         </td>

         <td class="appbox">
-            <div class="appbox-title">DIRECT</div>
+            <div class="appbox-title">UTILISED</div>
             <div style="padding-bottom:5px"><span class="appbox-value" id="total_use_direct_prc" style="color:#2ed52e">0</span></div>
             <div><span class="appbox-units" id="total_use_direct_kwh" style="color:#2ed52e">0</span> <span class="appbox-units" style="color:#2ed52e">kWh</span></div>
         </td>
@@ -136,6 +136,12 @@
             <div style="padding-bottom:5px"><span class="appbox-value" id="total_use_via_store_prc" style="color:#d52e2e">0</span></div>
             <div><span class="appbox-units" id="total_use_via_store_kwh" style="color:#d52e2e">0</span> <span class="appbox-units" style="color:#d52e2e">kWh</span></div>
         </td>
+
+        <td class="appbox">
+            <div class="appbox-title">SURPLUS</div>
+            <div style="padding-bottom:5px"><span class="appbox-value" id="total_export_prc" style="color:#dccc1f">0</span></div>
+            <div><span class="appbox-units" id="total_export_kwh" style="color:#dccc1f">0</span> <span class="appbox-units" style="color:#dccc1f">kWh</span></div>
+        </td>
     </tr>
     </table>

diff --git a/mysolarpv/mysolarpv.js b/mysolarpv/mysolarpv.js
index 86d1cb5..173d8b8 100644
--- a/mysolarpv/mysolarpv.js
+++ b/mysolarpv/mysolarpv.js
@@ -408,6 +408,11 @@ var app_mysolarpv = {
         $("#total_use_direct_kwh").html((total_use_direct_kwh).toFixed(1));
         $("#total_use_via_store_kwh").html((total_use_kwh-total_use_direct_kwh).toFixed(1));

+        $("#total_export_kwh").html((total_solar_kwh-total_use_direct_kwh).toFixed(1));
+        var solar_or_zero = 0;
+        if (total_solar_kwh>0) solar_or_zero = 1-(total_use_direct_kwh/total_solar_kwh);
+        $("#total_export_prc").html(Math.round(100*(solar_or_zero))+"%");
+
         options.xaxis.min = view.start;
         options.xaxis.max = view.end;

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.