From 90ce247e12862542ffe12bd2e0a760453d91e6ca Mon Sep 17 00:00:00 2001 From: Trystan Lea Date: Fri, 15 May 2026 22:22:27 +0100 Subject: [PATCH 01/10] myheatpump flot5 p1 --- Lib/appconf/appconf.js | 43 ++++++++++--------- Lib/appconf/appconf.php | 5 +-- .../myheatpump/myheatpump.js | 14 ++++-- .../myheatpump/myheatpump.php | 19 ++++---- .../myheatpump/myheatpump_bargraph.js | 17 ++++---- .../myheatpump/myheatpump_powergraph.js | 19 ++++---- 6 files changed, 62 insertions(+), 55 deletions(-) diff --git a/Lib/appconf/appconf.js b/Lib/appconf/appconf.js index 3a6ea94c..7347e3c6 100644 --- a/Lib/appconf/appconf.js +++ b/Lib/appconf/appconf.js @@ -576,25 +576,26 @@ var config = { } -var vue_config = new Vue({ - el: '#vue-config', - data: { - app_name: "App Name", - app_name_color: "#44b3e2", - app_description: "", - app_instructions: "", - config_name: "", - config_public: false, - config_items: [], - config_valid: false, - autogen_node: "", - autogen_feeds: [], - autogen_all_present: false, - autogen_status: "", - autogen_status_color: "#aaa", - - // Button only currently used by myheatpump app. - enable_process_daily: false +var vue_config_app = Vue.createApp({ + data: function() { + return { + app_name: "App Name", + app_name_color: "#44b3e2", + app_description: "", + app_instructions: "", + config_name: "", + config_public: false, + config_items: [], + config_valid: false, + autogen_node: "", + autogen_feeds: [], + autogen_all_present: false, + autogen_status: "", + autogen_status_color: "#aaa", + + // Button only currently used by myheatpump app. + enable_process_daily: false + }; }, methods: { @@ -833,4 +834,6 @@ var vue_config = new Vue({ config.reset_daily_data(); } } -}); \ No newline at end of file +}); + +var vue_config = vue_config_app.mount('#vue-config'); \ No newline at end of file diff --git a/Lib/appconf/appconf.php b/Lib/appconf/appconf.php index 146fb16d..ed5a3e02 100644 --- a/Lib/appconf/appconf.php +++ b/Lib/appconf/appconf.php @@ -5,9 +5,6 @@ $app_conf_version = time(); // Use timestamp for cache busting during development, replace with static version for production ?> - - -
@@ -149,4 +146,4 @@
- + \ No newline at end of file diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump.js index 74863c73..3c2febfa 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump.js @@ -1,3 +1,5 @@ +var urlParams = Object.fromEntries(new URLSearchParams(window.location.search)); + feed.apikey = apikey; feed.public_userid = public_userid; feed.public_username = public_username; @@ -523,13 +525,14 @@ $(".viewhistory").click(function () { $("#advanced-block").hide(); }); -$('#placeholder').bind("plothover", function (event, pos, item) { +document.getElementById('placeholder')?.addEventListener('plothover', function (event) { + const item = event.detail?.[1]; if (item) { if (previousPoint != item.datapoint) { previousPoint = item.datapoint; $("#tooltip").remove(); - if (viewmode == "bargraph") { + if (viewmode == "bargraph") { bargraph_tooltip(item); } else if (viewmode == "powergraph") { powergraph_tooltip(item); @@ -539,7 +542,8 @@ $('#placeholder').bind("plothover", function (event, pos, item) { }); // Auto click through to power graph -$('#placeholder').bind("plotclick", function (event, pos, item) { +document.getElementById('placeholder')?.addEventListener('plotclick', function (event) { + const item = event.detail?.[1]; if (item && !panning && viewmode == "bargraph") { last_bargraph_start = bargraph_start; @@ -562,7 +566,9 @@ $('#placeholder').bind("plotclick", function (event, pos, item) { } }); -$('#placeholder').bind("plotselected", function (event, ranges) { +document.getElementById('placeholder')?.addEventListener('plotselected', function (event) { + const ranges = event.detail?.[0]; + if (!ranges?.xaxis) return; var start = ranges.xaxis.from; var end = ranges.xaxis.to; panning = true; diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump.php b/apps/OpenEnergyMonitor/myheatpump/myheatpump.php index 3d0a699e..6e378106 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump.php +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump.php @@ -8,12 +8,8 @@ - - - - - - + + @@ -394,8 +390,9 @@ config.db = ; - - - - - + \ No newline at end of file diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js index 47cffa06..9af3b6f8 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js @@ -238,14 +238,14 @@ function bargraph_draw() { data["heatpump_heat_kwhd"] = daily_data[bargraph_mode+"_heat_kwh"]; - let color = 0; + let color = "#edc240"; if (bargraph_mode == "cooling") { color = "#66b0ff"; } bargraph_series.push({ data: data["heatpump_heat_kwhd"], color: color, - bars: { show: true, align: "center", barWidth: 0.75 * DAY, fill: 1.0, lineWidth: 0 }, + bars: { show: true, align: "center", barWidth: 0.75, fill: 1.0, lineWidth: 0 }, stack: true }); @@ -260,7 +260,7 @@ function bargraph_draw() { data["cooling_heat_kwhd"] = daily_data["cooling_heat_kwh"]; bargraph_series.push({ data: data["cooling_heat_kwhd"], color: "#66b0ff", - bars: { show: true, align: "center", barWidth: 0.75 * DAY, fill: 1.0, lineWidth: 0 } + bars: { show: true, align: "center", barWidth: 0.75, fill: 1.0, lineWidth: 0 } }); } } @@ -270,8 +270,8 @@ function bargraph_draw() { data["heatpump_elec_kwhd"] = daily_data[bargraph_mode+"_elec_kwh"]; bargraph_series.push({ - data: data["heatpump_elec_kwhd"], color: 1, - bars: { show: true, align: "center", barWidth: 0.75 * DAY, fill: 1.0, lineWidth: 0 }, + data: data["heatpump_elec_kwhd"], color: "#afd8f8", + bars: { show: true, align: "center", barWidth: 0.75, fill: 1.0, lineWidth: 0 }, stack: false }); @@ -354,7 +354,7 @@ function bargraph_draw() { data["immersion_kwhd"] = daily_data["immersion_kwh"]; bargraph_series.push({ data: data["immersion_kwhd"], color: 4, - bars: { show: true, align: "center", barWidth: 0.75 * DAY, fill: 0.8, lineWidth: 0 }, + bars: { show: true, align: "center", barWidth: 0.75, fill: 0.8, lineWidth: 0 }, stack: true }); @@ -369,7 +369,7 @@ function bargraph_draw() { data["boiler_kwhd"] = daily_data["boiler_kwh"]; bargraph_series.push({ data: data["boiler_kwhd"], color: "#ff9e80", - bars: { show: true, align: "center", barWidth: 0.75 * DAY, fill: 0.8, lineWidth: 0 }, + bars: { show: true, align: "center", barWidth: 0.75, fill: 0.8, lineWidth: 0 }, stack: true }); @@ -457,7 +457,8 @@ function bargraph_draw() { } } if ($('#placeholder').width()) { - var plot = $.plot($('#placeholder'), bargraph_series, options); + if (!window.Flot || typeof window.Flot.plot !== 'function') return; + var plot = window.Flot.plot($('#placeholder')[0], bargraph_series, options); $('#placeholder').append("
"); } } diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js index 656d97f5..1974373b 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js @@ -33,14 +33,14 @@ function powergraph_load() { "heatpump_cooling": { label: "Cooling", yaxis: 4, color: "#66b0ff", lines: { lineWidth: 0, show: true, fill: 0.15 } }, "heatpump_error": { label: "Error", yaxis: 4, color: "#F00", lines: { lineWidth: 0, show: true, fill: 0.15 } }, "heatpump_targetT": { label: "TargetT", yaxis: 2, color: "#ccc" }, - "heatpump_flowT": { label: "FlowT", yaxis: 2, color: 2 }, - "heatpump_returnT": { label: "ReturnT", yaxis: 2, color: 3 }, + "heatpump_flowT": { label: "FlowT", yaxis: 2, color: "#cb4b4b" }, + "heatpump_returnT": { label: "ReturnT", yaxis: 2, color: "#4da74d" }, "heatpump_outsideT": { label: "OutsideT", yaxis: 2, color: "#c880ff" }, "heatpump_roomT": { label: "RoomT", yaxis: 2, color: "#000" }, - "heatpump_flowrate": { label: "Flow rate", yaxis: 3, color: 6 }, + "heatpump_flowrate": { label: "Flow rate", yaxis: 3, color: "#afd8f8" }, "boiler_heat": { label: "Boiler", yaxis: 1, color: "#FF5349", lines: { show: true, fill: 0.2, lineWidth: 0.5 } }, - "heatpump_heat": { label: "Heat", yaxis: 1, color: 0, lines: { show: true, fill: 0.2, lineWidth: 0.5 } }, - "heatpump_elec": { label: "Electric", yaxis: 1, color: 1, lines: { show: true, fill: 0.3, lineWidth: 0.5 } }, + "heatpump_heat": { label: "Heat", yaxis: 1, color: "#edc240", lines: { show: true, fill: 0.2, lineWidth: 0.5 } }, + "heatpump_elec": { label: "Electric", yaxis: 1, color: "#afd8f8", lines: { show: true, fill: 0.3, lineWidth: 0.5 } }, "immersion_elec": { label: "Immersion", yaxis: 1, color: 4, lines: { show: true, fill: 0.3, lineWidth: 0.5 } }, "heatpump_dhwT": { label: dhw_label, yaxis: dhw_axis, color: "#0080ff" }, "heatpump_dhwTargetT": { label: dhw_target_label, yaxis: dhw_axis, color:"#99cbfc" }, @@ -717,6 +717,7 @@ function powergraph_draw() { } if ($('#placeholder').width()) { + if (!window.Flot || typeof window.Flot.plot !== 'function') return; // Remove keys var powergraph_series_without_key = []; for (var key in powergraph_series) { @@ -727,7 +728,7 @@ function powergraph_draw() { if (key == 'heatpump_dhwTargetT' && !show_dhw_temp) show = false; if (show) powergraph_series_without_key.push(powergraph_series[key]); } - $.plot($('#placeholder'), powergraph_series_without_key, options); + window.Flot.plot($('#placeholder')[0], powergraph_series_without_key, options); } // show symbol when live scrolling is active @@ -785,7 +786,8 @@ function draw_histogram(histogram) { legend: { position: "NW", noColumns: 6 } } if ($('#histogram').width() > 0) { - $.plot($('#histogram'), [{ data: sorted_histogram }], options); + if (!window.Flot || typeof window.Flot.plot !== 'function') return; + window.Flot.plot($('#histogram')[0], [{ data: sorted_histogram }], options); } } @@ -1071,7 +1073,8 @@ $("#configure_standby").click(function () { } }); -$('#histogram').bind("plothover", function (event, pos, item) { +document.getElementById('histogram')?.addEventListener('plothover', function (event) { + const item = event.detail?.[1]; if (item) { var z = item.dataIndex; if (previousPoint != item.datapoint) { From c14bc5102551cb9cbef66407816d539fdd185732 Mon Sep 17 00:00:00 2001 From: Trystan Lea Date: Fri, 15 May 2026 22:29:14 +0100 Subject: [PATCH 02/10] selection style --- apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js | 2 +- apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js index 9af3b6f8..6cdda3c6 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump_bargraph.js @@ -447,7 +447,7 @@ function bargraph_draw() { }, { show: false }], - selection: { mode: "x" }, + selection: { mode: 'x', color: '#e8cfac', visualization: 'fill' }, grid: { show: true, color: "#aaa", diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js index 1974373b..b60fbe52 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js @@ -708,7 +708,7 @@ function powergraph_draw() { // axisMargin:0 margin: { top: 30 } }, - selection: { mode: "x" }, + selection: { mode: 'x', color: '#e8cfac', visualization: 'fill' }, legend: { position: "NW", noColumns: 13 } } From a64cd885f0467cb6486c4eeca409666f00ab5b6b Mon Sep 17 00:00:00 2001 From: Trystan Lea Date: Fri, 15 May 2026 22:53:13 +0100 Subject: [PATCH 03/10] linewidths --- .../myheatpump/myheatpump_powergraph.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js index b60fbe52..73799179 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js @@ -33,14 +33,14 @@ function powergraph_load() { "heatpump_cooling": { label: "Cooling", yaxis: 4, color: "#66b0ff", lines: { lineWidth: 0, show: true, fill: 0.15 } }, "heatpump_error": { label: "Error", yaxis: 4, color: "#F00", lines: { lineWidth: 0, show: true, fill: 0.15 } }, "heatpump_targetT": { label: "TargetT", yaxis: 2, color: "#ccc" }, - "heatpump_flowT": { label: "FlowT", yaxis: 2, color: "#cb4b4b" }, - "heatpump_returnT": { label: "ReturnT", yaxis: 2, color: "#4da74d" }, - "heatpump_outsideT": { label: "OutsideT", yaxis: 2, color: "#c880ff" }, - "heatpump_roomT": { label: "RoomT", yaxis: 2, color: "#000" }, - "heatpump_flowrate": { label: "Flow rate", yaxis: 3, color: "#afd8f8" }, + "heatpump_flowT": { label: "FlowT", yaxis: 2, color: "#cb4b4b", lines: { lineWidth: 2.0 } }, + "heatpump_returnT": { label: "ReturnT", yaxis: 2, color: "#4da74d", lines: { lineWidth: 2.0 } }, + "heatpump_outsideT": { label: "OutsideT", yaxis: 2, color: "#c880ff", lines: { lineWidth: 2.0 } }, + "heatpump_roomT": { label: "RoomT", yaxis: 2, color: "#000", lines: { lineWidth: 2.0 } }, + "heatpump_flowrate": { label: "Flow rate", yaxis: 3, color: "#afd8f8", lines: { lineWidth: 2.0 } }, "boiler_heat": { label: "Boiler", yaxis: 1, color: "#FF5349", lines: { show: true, fill: 0.2, lineWidth: 0.5 } }, - "heatpump_heat": { label: "Heat", yaxis: 1, color: "#edc240", lines: { show: true, fill: 0.2, lineWidth: 0.5 } }, - "heatpump_elec": { label: "Electric", yaxis: 1, color: "#afd8f8", lines: { show: true, fill: 0.3, lineWidth: 0.5 } }, + "heatpump_heat": { label: "Heat", yaxis: 1, color: "#edc240", lines: { show: true, fill: 0.2, lineWidth: 2.0 } }, + "heatpump_elec": { label: "Electric", yaxis: 1, color: "#afd8f8", lines: { show: true, fill: 0.3, lineWidth: 2.0 } }, "immersion_elec": { label: "Immersion", yaxis: 1, color: 4, lines: { show: true, fill: 0.3, lineWidth: 0.5 } }, "heatpump_dhwT": { label: dhw_label, yaxis: dhw_axis, color: "#0080ff" }, "heatpump_dhwTargetT": { label: dhw_target_label, yaxis: dhw_axis, color:"#99cbfc" }, From 5d101e3ec08cb815d43b27925388a58c517068d3 Mon Sep 17 00:00:00 2001 From: Trystan Lea Date: Sat, 16 May 2026 11:09:17 +0100 Subject: [PATCH 04/10] mostly converting from milliseconds to seconds, but also linewidth and yaxes min/max autoscale settings --- .../myheatpump/myheatpump.js | 27 ++++++++++--------- .../myheatpump/myheatpump.php | 13 ++++----- .../myheatpump/myheatpump_bargraph.js | 22 +++++++-------- .../myheatpump/myheatpump_powergraph.js | 22 +++++++-------- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump.js index 3c2febfa..5eebe2bf 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump.js @@ -109,7 +109,7 @@ var realtime_cop_div_mode = "30min"; var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; // duration contants (milliseonds) -const MINUTE = 60 * 1000; +const MINUTE = 60; const HOUR = 60 * MINUTE; const DAY = 24 * HOUR; @@ -209,14 +209,14 @@ function show() { resize(); var date = new Date(); - var now = date.getTime(); + var now = date.getTime() * 0.001; - end = end_time * 1000; + end = end_time; if (now - end > HOUR) { $("#last_updated").show(); $("#live_table").hide(); - date.setTime(end); + date.setTime(end*1000); let h = date.getHours(); let m = date.getMinutes(); if (h < 10) h = "0" + h; @@ -250,13 +250,13 @@ function show() { // If this is a new dashboard there will be less than a days data // show power graph directly in this case - var timeWindow = (end - start_time * 1000); + var timeWindow = (end - start_time); if (timeWindow < 3 * DAY || viewmode == "powergraph") { if (timeWindow > 3 * DAY) timeWindow = DAY; var start = end - timeWindow; - if (urlParams.start != undefined) start = urlParams.start * 1000; - if (urlParams.end != undefined) end = urlParams.end * 1000; + if (urlParams.start != undefined) start = urlParams.start; + if (urlParams.end != undefined) end = urlParams.end; if (urlParams.hours != undefined) start = end - urlParams.hours * HOUR; view.start = start; @@ -269,10 +269,10 @@ function show() { } else { var timeWindow = 30 * DAY; var start = end - timeWindow; - if (start < (start_time * 1000)) start = start_time * 1000; + if (start < start_time) start = start_time; - if (urlParams.start != undefined) start = urlParams.start * 1000; - if (urlParams.end != undefined) end = urlParams.end * 1000; + if (urlParams.start != undefined) start = urlParams.start; + if (urlParams.end != undefined) end = urlParams.end; bargraph_load(start, end); bargraph_draw(); @@ -508,9 +508,9 @@ $(".viewhistory").click(function () { $(".powergraph-navigation").hide(); var timeWindow = 30 * DAY; // var end = (new Date()).getTime(); - var end = end_time * 1000; + var end = end_time; var start = end - timeWindow; - if (start < (start_time * 1000)) start = start_time * 1000; + if (start < start_time) start = start_time; if (last_bargraph_start && last_bargraph_end) { start = last_bargraph_start; @@ -550,9 +550,10 @@ document.getElementById('placeholder')?.addEventListener('plotclick', function ( last_bargraph_end = bargraph_end; var z = item.dataIndex; - view.start = data["heatpump_elec_kwhd"][z][0]; + view.start = data["heatpump_elec_kwhd"][z][0]*1; view.end = view.start + DAY; viewmode = "powergraph"; + powergraph_load(); $(".bargraph-navigation").hide(); diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump.php b/apps/OpenEnergyMonitor/myheatpump/myheatpump.php index 6e378106..25afe320 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump.php +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump.php @@ -6,12 +6,13 @@ - - - - - - +