Skip to content

Commit

Permalink
Merge branch 'master' of github.com:emoncms/app
Browse files Browse the repository at this point in the history
  • Loading branch information
TrystanLea committed Nov 15, 2023
2 parents b35ed94 + 0b5ffd6 commit 63951b9
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 35 deletions.
63 changes: 56 additions & 7 deletions apps/OpenEnergyMonitor/myheatpump/myheatpump.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ config.app = {
"heatpump_outsideT":{"type":"feed", "autoname":"heatpump_outsideT", "engine":5, "optional":true, "description":"Outside temperature"},
"heatpump_roomT":{"type":"feed", "autoname":"heatpump_roomT", "engine":5, "optional":true, "description":"Room temperature"},
"heatpump_flowrate":{"type":"feed", "autoname":"heatpump_flowrate", "engine":5, "optional":true, "description":"Flow rate"},
"heatpump_dhw":{"type":"feed", "autoname":"heatpump_dhw", "optional":true, "description":"Heating Hot Water"},
"heatpump_ch":{"type":"feed", "autoname":"heatpump_ch", "optional":true, "description":"Central Heating"},
"heatpump_dhw":{"type":"feed", "autoname":"heatpump_dhw", "optional":true, "description":"Status of Hot Water circuit (non-zero when running)"},
"heatpump_ch":{"type":"feed", "autoname":"heatpump_ch", "optional":true, "description":"Status of Central Heating circuit (non-zero when running)"},
"start_date":{"type":"value", "default":0, "name": "Start date", "description":_("Start date for all time values (unix timestamp)")},
};
config.feeds = feed.list();
Expand Down Expand Up @@ -458,6 +458,16 @@ $('.bargraph-alltime').click(function () {
bargraph_draw();
});

$('.bargraph-day').click(function () {
view.timewindow(1.0);
$(".bargraph-navigation").hide();
viewmode = "powergraph";
powergraph_load();
powergraph_draw();
$(".powergraph-navigation").show();
$("#advanced-toggle").show();
});

$('.bargraph-week').click(function () {
var timeWindow = (3600000*24.0*7);
var end = (new Date()).getTime();
Expand All @@ -476,6 +486,24 @@ $('.bargraph-month').click(function () {
bargraph_draw();
});

$('.bargraph-quarter').click(function () {
var timeWindow = (3600000*24.0*91);
var end = (new Date()).getTime();
var start = end - timeWindow;
if (start<(start_time*1000)) start = start_time * 1000;
bargraph_load(start,end);
bargraph_draw();
});

$('.bargraph-year').click(function () {
var timeWindow = (3600000*24.0*365);
var end = (new Date()).getTime();
var start = end - timeWindow;
if (start<(start_time*1000)) start = start_time * 1000;
bargraph_load(start,end);
bargraph_draw();
});

$("#carnot_enable").click(function(){

if ($("#carnot_enable_prc")[0].checked && !$("#carnot_enable")[0].checked) {
Expand Down Expand Up @@ -594,9 +622,9 @@ function powergraph_load()

let style = {lineWidth: 0, show:true, fill:0.15};
if (all_same_interval) {
powergraph_series.push({label:"CH", data:remove_null_values(data["heatpump_ch"]), yaxis:4, color:"#FD8", lines:style});
powergraph_series.push({label:"CH", data:remove_null_values(data["heatpump_ch"]), yaxis:4, color:"#FB6", lines:style});
} else {
powergraph_series.push({label:"CH", data:data["heatpump_ch"], yaxis:4, color:"#FD8", lines:style});
powergraph_series.push({label:"CH", data:data["heatpump_ch"], yaxis:4, color:"#FB6", lines:style});
}
}
if (feeds["heatpump_flowT"]!=undefined) {
Expand Down Expand Up @@ -1093,7 +1121,7 @@ function powergraph_draw()
yaxes: [
{min: 0, font: style,reserveSpace:false},
{font: style,reserveSpace:false},
{font: style,reserveSpace:false},
{min: 0, font: {size:flot_font_size, color: "#44b3e2"},reserveSpace:false},
{min: 0, max: 1, show: false, reserveSpace:false}
],
grid: {
Expand All @@ -1107,7 +1135,7 @@ function powergraph_draw()
margin:{top:30}
},
selection: { mode: "x" },
legend:{position:"NW", noColumns:7}
legend:{position:"NW", noColumns:10}
}
if ($('#placeholder').width()) {
$.plot($('#placeholder'),powergraph_series,options);
Expand Down Expand Up @@ -1151,6 +1179,23 @@ function bargraph_load(start,end)
for (var z in data["heatpump_elec_kwhd"]) {
elec_kwh_in_window += data["heatpump_elec_kwhd"][z][1];
}

// add series that shows COP points for each day
if (heat_enabled) {
cop_data = [];
for (var z in data["heatpump_elec_kwhd"]) {
time = data["heatpump_elec_kwhd"][z][0];
elec = data["heatpump_elec_kwhd"][z][1];
heat = data["heatpump_heat_kwhd"][z][1];
if (elec && heat) {
cop_data[z] = [ time, heat / elec ];
}
}
bargraph_series.push({
data: cop_data, color: "#44b3e2", yaxis:3,
points: { show: true }
});
}
}

if (feeds["heatpump_outsideT"]!=undefined) {
Expand All @@ -1159,7 +1204,7 @@ function bargraph_load(start,end)
data["heatpump_outsideT_daily"] = feed.getdata(feeds["heatpump_outsideT"].id,start,end,"daily",1,0);
bargraph_series.push({
data: data["heatpump_outsideT_daily"], color: 4, yaxis:2,
lines: { show: true, align: "center", fill: false}, points: { show: true }
lines: { show: true, align: "center", fill: false}, points: { show: false }
});
}
}
Expand Down Expand Up @@ -1190,6 +1235,10 @@ function bargraph_draw()
// labelWidth:-5
reserveSpace:false,
// max:40
},{
font: {size:flot_font_size, color:"#44b3e2"},
reserveSpace:false,
min: 0
}],
selection: { mode: "x" },
grid: {
Expand Down
57 changes: 29 additions & 28 deletions apps/OpenEnergyMonitor/myheatpump/myheatpump.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,26 @@
<div class="block-bound">

<div class="bargraph-navigation">
<!--<div class="bluenav bargraph-other">OTHER</div>-->
<div class="bluenav bargraph-alltime">ALL TIME</div>
<div class="bluenav bargraph-alltime">ALL</div>
<div class="bluenav bargraph-year">YEAR</div>
<div class="bluenav bargraph-quarter">3 MONTHS</div>
<div class="bluenav bargraph-month">MONTH</div>
<div class="bluenav bargraph-week">WEEK</div>
<div class="bluenav bargraph-day">DAY</div>
</div>

<div class="powergraph-navigation" style="display:none">
<div class="bluenav viewhistory">BACK</div>
<span class="bluenav" id="right" >></span>
<span class="bluenav" id="left" ><</span>
<span class="bluenav" id="zoomout" >-</span>
<span class="bluenav" id="zoomin" >+</span>
<span class="bluenav time dmy" time='720'>M</span>
<span class="bluenav time dmy" time='168'>W</span>
<span class="bluenav time" time='24'>D</span>
<span class="bluenav time" time='1'>H</span>
<div class="bluenav viewhistory" title="Back to daily summary">BACK</div>
<span class="bluenav" id="right" title="Scroll right">&gt;</span>
<span class="bluenav" id="left" title="Scroll left">&lt;</span>
<span class="bluenav" id="zoomout" title="Zoom out">-</span>
<span class="bluenav" id="zoomin" title="Zoom in">+</span>
<span class="bluenav time dmy" time='720' title="Last 30 days">M</span>
<span class="bluenav time dmy" time='168' title="Last 7 days">W</span>
<span class="bluenav time" time='24' title="Last 24 hours">D</span>
<span class="bluenav time" time='6' title="Last 6 hours">6</span>
<span class="bluenav time" time='1' title="Last hour">H</span>
</div>

<div class="block-title">HISTORY</div>
</div>

<div style="background-color:#fff; padding:10px;">
Expand All @@ -100,10 +101,22 @@
COP in window: <b id="window-cop"></b> <span id="window-carnot-cop"></span>
</div>
</div>

<div id="advanced-block" style="background-color:#fff; padding:10px; display:none">
<div style="color:#000">
<p id="show_flow_rate_bound" style="display:none"><b>Show flow rate:</b> <input id="show_flow_rate" type="checkbox" style="margin-top:-4px; margin-left:7px"></p>
<div id="dhw_stats" style="display: none">
<p><b>Heating</b>:
Electricity consumed: <span id="ch_elec_kwh"></span> kWh
&raquo; heat produced: <span id="ch_heat_kwh"></span> kWh
= COP <b><span id="ch_cop"></span></b>
</p>
<p><b>Hot Water</b>:
Electricity consumed: <span id="dhw_elec_kwh"></span> kWh
&raquo; heat produced: <span id="dhw_heat_kwh"></span> kWh
= COP <b><span id="dhw_cop"></span></b>
</p>
</div>
<hr style="margin:10px 0px 10px 0px">

<table class="table">
<tr>
Expand All @@ -118,19 +131,7 @@
<tbody id="stats"></tbody>
</table>

<div id="dhw_stats" style="display: none">
<hr style="margin:10px 0px 10px 0px">
<p><b>Heating</b>:
Electricity consumed: <span id="ch_elec_kwh"></span> kWh
&raquo; heat produced: <span id="ch_heat_kwh"></span> kWh
= COP <b><span id="ch_cop"></span></b>
</p>
<p><b>Hot Water</b>:
Electricity consumed: <span id="dhw_elec_kwh"></span> kWh
&raquo; heat produced: <span id="dhw_heat_kwh"></span> kWh
= COP <b><span id="dhw_cop"></span></b>
</p>
</div>
<p id="show_flow_rate_bound" style="display:none"><b>Show flow rate:</b> <input id="show_flow_rate" type="checkbox" style="margin-top:-4px; margin-left:7px"></p>

<hr style="margin:10px 0px 10px 0px">
<p><b>Standby</b></p>
Expand Down

0 comments on commit 63951b9

Please sign in to comment.