diff --git a/.gitignore b/.gitignore index 95f30cd..ab07c40 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ Cargo.lock test_devices.conf -*.db \ No newline at end of file +*.db + +midea_ac_lan/ \ No newline at end of file diff --git a/midea.py b/midea.py new file mode 100644 index 0000000..decb0ab --- /dev/null +++ b/midea.py @@ -0,0 +1,3 @@ +import midea_ac_lan.midea.core as midea_core + +midea_core \ No newline at end of file diff --git a/resources/js/main.js b/resources/js/main.js index 7f0edd8..2748ffe 100644 --- a/resources/js/main.js +++ b/resources/js/main.js @@ -123,7 +123,7 @@ async function startup() { let device_power_draw = document.createElement('label'); device_power_draw.innerText = device_state["power_draw"] + " W"; let device_power_draw_graph_button = document.createElement('button'); - device_power_draw_graph_button.onclick = async () => { await render_graph(device_id) }; + device_power_draw_graph_button.onclick = async () => { await render_graph(device_id, device_descriptor) }; let device_power_draw_graph_button_icon = document.createElement('i'); device_power_draw_graph_button_icon.className = "fa fa-chart-bar"; @@ -190,7 +190,7 @@ async function change_device_name(plug, name) { } } -async function render_graph(plug) { +async function render_graph(plug, name) { // remove old graph, if present let old = document.getElementById("chart"); @@ -218,14 +218,14 @@ async function render_graph(plug) { for (let i = 0; i < data.length; i++) { let [time, watts] = data[i]; - x.push(time); + x.push(new Date(time * 1000)); y.push(watts); } const chart_data = { labels: x, datasets: [{ - label: plug, + label: name, data: y, fill: false, borderColor: 'rgb(75, 192, 192)', @@ -236,7 +236,26 @@ async function render_graph(plug) { new Chart(chart, { type: 'line', data: chart_data, + options: { + scales: { + y: { + beginAtZero: true + }, + x: { + type: 'time', + time: { + displayFormats: { + 'day': 'DD.MM hh:mm', + 'hour': 'DD.MM hh:mm', + 'week': 'DD.MM hh:mm', + 'month': 'DD.MM hh:mm', + } + } + } + }, + locale: 'de-DE' + } }); - document.getElementById("chart_div").appendChild(chart); + document.getElementById("main").appendChild(chart); } \ No newline at end of file diff --git a/resources/static/index.html b/resources/static/index.html index ef2c9c1..26023d9 100644 --- a/resources/static/index.html +++ b/resources/static/index.html @@ -9,8 +9,10 @@
-
+ +