Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonFair committed Jun 16, 2023
1 parent 384d29b commit 42d19aa
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tasmotapm/usr/local/emhttp/plugins/tasmotapm/status.page
@@ -1,5 +1,6 @@
Menu="Dashboard"
Icon="ups"
Cond="version_compare(parse_ini_file('/etc/unraid-version')['version'],'6.12.0-beta6', '<')"
---
<style type="text/css">
<?php
Expand Down Expand Up @@ -121,4 +122,4 @@ $(function() {
// reload sorting to get the stored data (cookie)
sortTable($('#db-box1'),$.cookie('db-box1'));
});
</script>
</script>
115 changes: 115 additions & 0 deletions src/tasmotapm/usr/local/emhttp/plugins/tasmotapm/statusmove.page
@@ -0,0 +1,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>

0 comments on commit 42d19aa

Please sign in to comment.