forked from Flippo24/tasmotapm-unraid
/
statusmove.page
115 lines (95 loc) · 4.96 KB
/
statusmove.page
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Menu="Dashboard:0"
Cond="version_compare(parse_ini_file('/etc/unraid-version')['version'],'6.11.9','>')"
---
<?PHP
/*
Create a .page file based on this example file and store the file in your plugin directory
Make sure this file has a unique name not used by the GUI or other plugins
This is an example configuration which is used to add custom tiles to the dashboard
Placement of one or more custom tiles is done under column1, column2 or column3
A column can have as many new custom tiles as needed, each custom tile is a <tbody> element
Each tile must have these two properties set:
"_(description)_" - this is the (translated) description shown in the Content Manager window
"_(Tile tile)_" - this is the (translated) title of the tile shown in bold on the screen
The content of the tile can be any text as required by your plugin, this content is placed inside the <td> element
A number of predefined spans are available to make fields of certain widths and maybe used to follow the GUI alignment
These are:
<span class="w18">
<span class="w26">
<span class="w36">
<span class="w44">
<span class="w72">
*/
$pluginname = "tasmota"; // substitute this entry with the name of your plugin
$tasmotapm_cfg = parse_plugin_cfg("tasmotapm",true);
$mytiles[$pluginname]['column1'] =
<<<EOT
<tbody title="_(Tasmota)_">
<tr><td>_(Tasmota Power Monitor)_<a href="/Dashboard/Settings/TasmotaPMSettings" title="_(Go to Tasmota settings)_"><i class="fa fa-fw fa-cog control"></i></a></td></tr>
<tr><td><i class='icon-ups'></i><div class='section'><span id='load'>_(Usage)_: <span class='tasmotapm-energy-power'>0</span></span><br><br></div></td></tr>
<tr class="tasmotapm_view">
<td><span class="w26">Today:</span><span class="w26 tasmotapm-energy-today"></span>
<span class="w26 tasmotapm-costs_today"></td>
</tr>
<tr class="tasmotapm_view">
<td><span class="w26">Yesterday:</span><span class="w26 tasmotapm-energy-yesterday"></span>
<span class="w26 tasmotapm-costs_yesterday"></span> </td>
</tr>
<tr class="tasmotapm_view">
<td><span class="w26">Total:</span>
<span class="w26 tasmotapm-energy-total"></span>
<span class="w26 tasmotapm-costs_total"></span></span></td>
</tr>
<tr class="tasmotapm_view">
<td><span class="w26">Power</span>
<span class="w26 tasmotapm-energy-power"></span></td>
</tr>
<tr class="tasmotapm_view">
<td><span class="w26">Voltage</span>
<span class="w26 tasmotapm-energy-voltage"></span></td>
</tr>
<tr class="tasmotapm_view">
<td><span class="w26">Current</span>
<span class="w26 tasmotapm-energy-current"></span></td>
</tr>
<tr class="tasmotapm_view">
<td><span class="w26">Apparent power</span>
<span class="w26 tasmotapm-energy-apparentpower"></span></td>
</tr>
<tr class="tasmotapm_view">
<td><span class="w26">Reactive power</span>
<span class="w26 tasmotapm-energy-reactivepower"></span></td>
</tr>
<tr class="tasmotapm_view">
<td><span class="w26">Efficiency</span>
<span class="w26 tasmotapm-energy-efficiency"></span></td>
</tr>
</tbody>
EOT;
?>
<script>
function tasmotapm_status() {
$.getJSON("/plugins/tasmotapm/status.php", (data) => {
if (data) {
$(".tasmotapm-energy-power").html(data.Power+" W");
$(".tasmotapm-energy-today").html(data.Today+" kWh");
$(".tasmotapm-energy-yesterday").html(data.Yesterday+" kWh");
$(".tasmotapm-energy-total").html(data.Total+" kWh");
$(".tasmotapm-energy-voltage").html(data.Voltage+" V");
$(".tasmotapm-energy-current").html(data.Current+" A");
$(".tasmotapm-energy-apparentpower").html(data.ApparentPower+" VA");
$(".tasmotapm-energy-reactivepower").html(data.ReactivePower+" VAr");
$(".tasmotapm-energy-efficiency").html((Number.parseFloat(data.Factor) * 100).toFixed()+" %");
$(".tasmotapm-costs_today").html((Number.parseFloat(data.Costs_Price) * Number.parseFloat(data.Today)).toFixed(2)+" "+data.Costs_Unit);
$(".tasmotapm-costs_yesterday").html((Number.parseFloat(data.Costs_Price) * Number.parseFloat(data.Yesterday)).toFixed(2)+" "+data.Costs_Unit);
$(".tasmotapm-costs_total").html((Number.parseFloat(data.Costs_Price) * Number.parseFloat(data.Total)).toFixed(2)+" "+data.Costs_Unit);
$(".tasmotapm-costs_unit").html(data.Costs_Unit);
}
});
if (<?=$tasmotapm_cfg['UIREFRESH'];?>) {
setInterval(tasmotapm_status, <?=$tasmotapm_cfg['UIREFRESH'];?>);
}}
$(function(){
tasmotapm_status();
});
</script>