This commit is contained in:
jhartworks
2025-01-31 13:34:41 +01:00
parent da2341a9f3
commit 06a0e373bf
4 changed files with 298 additions and 0 deletions
+89
View File
@@ -0,0 +1,89 @@
{
"elements":
[
{ "type": "NumberSpinner", "Name": "Price", "caption": "Strompreis", "digits": 2},
{
"type": "List",
"name": "Counters",
"caption": "Zählerliste",
"add": true,
"delete": true,
"sort": {
"column": "Name",
"direction": "ascending"
},
"columns": [{
"caption": "InstanceID",
"name": "InstanceID",
"width": "75px",
"add": 0,
"edit": {
"type": "SelectInstance"
}
},
{
"caption": "Name",
"name": "Name",
"width": "auto",
"add": ""
},
{
"caption": "Gesamtverbrauch",
"name": "Total",
"width": "40px",
"edit": {
"type": "SelectVariable",
"validVariableTypes": [7]
}
},
{
"caption": "Monatsverbrauch",
"name": "Monthly",
"width": "75px",
"edit": {
"type": "SelectVariable",
"validVariableTypes": [7]
}
},
{
"caption": "Wochenverbrauch",
"name": "Weekly",
"width": "75px",
"edit": {
"type": "SelectVariable",
"validVariableTypes": [7]
}
},
{
"caption": "Tagesverbrauch",
"name": "Daily",
"width": "75px",
"edit": {
"type": "SelectVariable",
"validVariableTypes": [7]
}
},
{
"caption": "Limit",
"name": "Limit",
"width": "75px",
"edit": {
"type": "NumberSpinner",
"digits": 2
}
}
]
}
],
"actions":
[
],
"status":
[
]
}
+14
View File
@@ -0,0 +1,14 @@
{
"id": "{D0DA85AB-1BAD-C36C-A3FD-1C2660F96F1C}",
"name": "CounterTable",
"type": 3,
"vendor": "J.H. Artworks",
"aliases":
[
],
"url": "https://jh-artworks.com",
"parentRequirements": [],
"childRequirements": [],
"implemented": [],
"prefix": "CT"
}
+182
View File
@@ -0,0 +1,182 @@
<?
// Klassendefinition
class CounterTable extends IPSModule {
// Überschreibt die interne IPS_Create($id) Funktion
public function Create() {
// Diese Zeile nicht löschen.
parent::Create();
$this->RegisterPropertyFloat("Price",0.23);
$this->ReadPropertyString("Counters","");
$this->RegisterVariableString("htmlOutput", "Zählerübersicht",["PRESENTATION"=> VARIABLE_PRESENTATION_LEGACY, "PROFILE" => "~HTMLBox"],0);
}
// Überschreibt die intere IPS_ApplyChanges($id) Funktion
public function ApplyChanges() {
// Diese Zeile nicht löschen
parent::ApplyChanges();
$this->checkTable();
}
public function RequestAction($Ident, $Value) {
$varid = $this->GetIDForIdent($Ident);
SetValue($varid, $Value);
}
public function checkTable(){
$Idvalue = $this->ReadPropertyFloat("Price");
$arrString = $this->ReadPropertyString("Counters");
$arr = json_decode($arrString);
print_r($arr);
/*
'<tr style="background-color:'.$ColorGrenzeGesamt.';">
<td style="text-align:left;">
Gesamt
</td>
<td>
'.$ZaehlerGesamtGesamt.'
</td>
<td>
'.$ZaehlerGesamtMonat.'
</td>
<td>
'.$GrenzeZaehlerGesamt.' kWh
</td>
<td>
'.$ZaehlerGesamtTag.'
</td>
<td>
'.$KostenGesamt.'€
</td>
</tr>'
*/
}
public function createTable($data)
{
$htmlprefix =' <html>
<style>
table, td {
border-collapse: separate;
border-spacing: 5px;
}
td {
color:#000000;
font-family:Arial;
font-size:14pt;
width:150px;
text-align:center;
}
th {
color:#000000;
font-family:Arial;
font-size:14pt;
width:150px;
text-align:center;
}
</style>
<body>
<table style="hight:100%;background-color:lightgrey;border:2px solid green;">
<thead>
<tr>
<th style="">
</th>
<th>
Gesamt:
</th>
<th>
Monat:
</th>
<th>
Monatsgerenze:
</th>
<th>
Heute:
</th>
<th>
Kosten:
</th>
</tr>
</thead>
<tr style="background-color:'.$ColorGrenzeGesamt.';">
<td style="text-align:left;">
Gesamt
</td>
<td>
'.$ZaehlerGesamtGesamt.'
</td>
<td>
'.$ZaehlerGesamtMonat.'
</td>
<td>
'.$GrenzeZaehlerGesamt.' kWh
</td>
<td>
'.$ZaehlerGesamtTag.'
</td>
<td>
'.$KostenGesamt.'€
</td>
</tr>';
$htmlsuffix = '
<tr>
</tr>
</table>
';
SetValueString($this->GetIDForIdent("htmlOutput"),$htmlprefix.$data.$htmlsuffix);
}
}
?>
+13
View File
@@ -0,0 +1,13 @@
{
"id": "{FB801A08-0A7D-38F0-C5C1-C0B9147B11F5}",
"author": "J.H. Artworks",
"name": "Counters",
"url": "https://jh-artworks.com",
"compatibility": {
"version": "6.0",
"date": 1491343200
},
"version": "1.0",
"build": 1,
"date": 0
}