Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
TrystanLea committed May 17, 2021
2 parents f2b3d4c + e3e3edf commit 84b8d0f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function app_controller()
{
global $mysqli,$path,$session,$route,$user,$settings,$v;
// Force cache reload of css and javascript
$v = 12;
$v = 13;

$result = false;

Expand Down
10 changes: 5 additions & 5 deletions apps/OpenEnergyMonitor/myheatpump/myheatpump.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function show()

if (elec_enabled) {
meta["heatpump_elec_kwh"] = feed.getmeta(feeds["heatpump_elec_kwh"].id);
meta["heatpump_elec"] = feed.getmeta(feeds["heatpump_elec"].id);
if (feeds["heatpump_elec"]!=undefined) meta["heatpump_elec"] = feed.getmeta(feeds["heatpump_elec"].id);
if (meta["heatpump_elec_kwh"].start_time>start_time) start_time = meta["heatpump_elec_kwh"].start_time;
}

Expand Down Expand Up @@ -237,8 +237,8 @@ $('#placeholder').bind("plothover", function (event, pos, item) {
{
var itemTime = item.datapoint[0];
var elec_kwh = 0; var heat_kwh = 0;
if (elec_enabled) elec_kwh = data["heatpump_elec_kwhd"][z][1];
if (heat_enabled) heat_kwh = data["heatpump_heat_kwhd"][z][1];
if (elec_enabled && data["heatpump_elec_kwhd"].length) elec_kwh = data["heatpump_elec_kwhd"][z][1];
if (heat_enabled && data["heatpump_heat_kwhd"].length) heat_kwh = data["heatpump_heat_kwhd"][z][1];
var COP = heat_kwh / elec_kwh;

var d = new Date(itemTime);
Expand Down Expand Up @@ -349,7 +349,7 @@ function powergraph_load()
var interval = ((end-start)*0.001) / npoints;
interval = view.round_interval(interval);

if (elec_enabled) interval = Math.round(interval/meta["heatpump_elec"].interval)*meta["heatpump_elec"].interval
if (elec_enabled && meta["heatpump_elec"]!=undefined) interval = Math.round(interval/meta["heatpump_elec"].interval)*meta["heatpump_elec"].interval
if (heat_enabled) interval = Math.round(interval/meta["heatpump_heat"].interval)*meta["heatpump_heat"].interval

var intervalms = interval * 1000;
Expand Down Expand Up @@ -385,7 +385,7 @@ function powergraph_load()
}
powergraph_series.push({label:"Heat Output", data:data["heatpump_heat"], yaxis:1, color:0, lines:{show:true, fill:0.2, lineWidth:0.5}});
}
if (elec_enabled) {
if (elec_enabled && meta["heatpump_elec"]!=undefined) {
if (interval==meta["heatpump_elec"].interval) {
data["heatpump_elec"] = feed.getdata(feeds["heatpump_elec"].id,start,end,interval,1,1);
} else {
Expand Down
35 changes: 28 additions & 7 deletions apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@
<h5 class="electric-title mb-0 text-md-larger text-light"><span class="battery_charge_discharge_title"><?php echo _('BATTERY POWER') ?></span></h5>
<h2 class="power-value display-md-3 display-lg-2 my-0 text-quaternary"><span class="battery_charge_discharge">-</span><span class="power-unit"></span></h2>
</div>
<div class="text-xs-center">
<h5 class="electric-title mb-0 text-md-larger text-light"><span class="discharge_time_left_title"><?php echo _('BATTERY TIME LEFT') ?></span></h5>
<h2 class="power-value display-md-3 display-lg-2 my-0 text-quaternary"><span class="discharge_time_left">-</span></h2>
</div>
<div class="text-xs-center">
<h5 class="electric-title mb-0 text-md-larger text-light"><?php echo _('STATE OF CHARGE') ?></h5>
<h2 class="power-value display-md-3 display-lg-2 my-0 text-quaternary"><span class="battery_soc">-</span>%</h2>
Expand Down Expand Up @@ -385,7 +389,8 @@ function getTranslations(){
"battery_discharge_kwh":{"optional":true, "type":"feed", "autoname":"battery_discharge_kwh", "engine":"5", "description":"Battery discharge energy in kWh"},

// Other options
"kw":{"type":"checkbox", "default":0, "name": "Show kW", "description":_("Display power as kW")}
"kw":{"type":"checkbox", "default":0, "name": "Show kW", "description": "Display power as kW"},
"battery_capacity_kwh":{"type":"value", "default":0, "name":"Battery Capacity", "description":"Battery capacity in kWh"}
}
config.name = "<?php echo $name; ?>";
config.db = <?php echo json_encode($config); ?>;
Expand Down Expand Up @@ -612,16 +617,32 @@ function livefn()
$(".generationnow").html(gen_now);
$(".usenow").html(use_now);
$(".battery_soc").html(battery_soc_now);

if (battery_charge_now>0) {

const net_battery_charge = battery_charge_now - battery_discharge_now;
if (net_battery_charge>0) {
$(".battery_charge_discharge_title").html("BATTERY CHARGING");
$(".battery_charge_discharge").html(battery_charge_now)
} else if (battery_discharge_now>0) {
$(".battery_charge_discharge").html(net_battery_charge);
$(".discharge_time_left").html("--");
} else if (net_battery_charge<0) {
if (config.app && config.app.kw && config.app.battery_capacity_kwh.value > 0 && battery_soc_now >= 0) {
const total_capacity = config.app.battery_capacity_kwh.value * 1000;
const energy_remaining = total_capacity * battery_soc_now / 100;
const total_time_left_mins = (energy_remaining / -(net_battery_charge)) * 60;

const hours_left = Math.floor(total_time_left_mins / 60);
const mins_left = Math.floor(total_time_left_mins % 60);
const battery_time_left_text = `${hours_left}h ${mins_left}m`
$(".discharge_time_left").html(battery_time_left_text);
} else {
$(".discharge_time_left").html("--");
}

$(".battery_charge_discharge_title").html("BATTERY DISCHARGING");
$(".battery_charge_discharge").html(battery_discharge_now)
$(".battery_charge_discharge").html(-net_battery_charge);
} else {
$(".battery_charge_discharge_title").html("BATTERY POWER");
$(".battery_charge_discharge").html(0)
$(".battery_charge_discharge").html(0);
$(".discharge_time_left").html("--");
}

// Only redraw the graph if its the power graph and auto update is turned on
Expand Down
4 changes: 3 additions & 1 deletion module.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"name" : "App",
"version" : "2.2.6"
"version" : "2.2.6",
"location" : "/var/www/emoncms/Modules",
"branches_available": ["stable","master","menu_v3"]
}

0 comments on commit 84b8d0f

Please sign in to comment.