initial commit
This commit is contained in:
commit
faa518ccd8
10 files changed
+704
No files matched your search
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"type": "Label",
|
||||
"caption": "Values are calculated and reset only by the associated main module. This form controls visibility only; hidden values remain available in the background."
|
||||
},
|
||||
{
|
||||
"type": "ExpansionPanel",
|
||||
"caption": "Display variables",
|
||||
"expanded": true,
|
||||
"items": [
|
||||
{
|
||||
"type": "CheckBox",
|
||||
"name": "ShowTotalEnergy",
|
||||
"caption": "Show total energy"
|
||||
},
|
||||
{
|
||||
"type": "CheckBox",
|
||||
"name": "ShowTotalCost",
|
||||
"caption": "Show total cost"
|
||||
},
|
||||
{
|
||||
"type": "CheckBox",
|
||||
"name": "ShowDayEnergy",
|
||||
"caption": "Show daily energy"
|
||||
},
|
||||
{
|
||||
"type": "CheckBox",
|
||||
"name": "ShowDayCost",
|
||||
"caption": "Show daily cost"
|
||||
},
|
||||
{
|
||||
"type": "CheckBox",
|
||||
"name": "ShowMonthEnergy",
|
||||
"caption": "Show monthly energy"
|
||||
},
|
||||
{
|
||||
"type": "CheckBox",
|
||||
"name": "ShowMonthCost",
|
||||
"caption": "Show monthly cost"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [],
|
||||
"status": []
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"translations": {
|
||||
"de": {
|
||||
"Energy Counter Display": "Energiezähler Anzeige",
|
||||
"Values are calculated and reset only by the associated main module. This form controls visibility only; hidden values remain available in the background.": "Die Werte werden ausschließlich durch das zugehörige Hauptmodul berechnet und zurückgesetzt. Hier wird nur ihre Sichtbarkeit gesteuert; ausgeblendete Werte bleiben im Hintergrund vorhanden.",
|
||||
"Display variables": "Anzuzeigende Variablen",
|
||||
"Show total energy": "Gesamtenergie anzeigen",
|
||||
"Show total cost": "Gesamtkosten anzeigen",
|
||||
"Show daily energy": "Tagesenergie anzeigen",
|
||||
"Show daily cost": "Tageskosten anzeigen",
|
||||
"Show monthly energy": "Monatsenergie anzeigen",
|
||||
"Show monthly cost": "Monatskosten anzeigen",
|
||||
"Total Energy": "Gesamtenergie",
|
||||
"Total Cost": "Gesamtkosten",
|
||||
"Daily Energy": "Tagesenergie",
|
||||
"Daily Cost": "Tageskosten",
|
||||
"Monthly Energy": "Monatsenergie",
|
||||
"Monthly Cost": "Monatskosten"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "{C96F6499-8F3E-4EBF-AF8D-2C45E989D2F6}",
|
||||
"name": "EnergyCounterChild",
|
||||
"type": 3,
|
||||
"vendor": "J.H. Artworks",
|
||||
"aliases": [
|
||||
"Energy Counter Display"
|
||||
],
|
||||
"url": "https://jh-artworks.com",
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "ECC"
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
class EnergyCounterChild extends IPSModule
|
||||
{
|
||||
private const ENERGY_PROFILE = 'EnergyCounter.kWh';
|
||||
private const COST_PROFILE = 'EnergyCounter.EUR';
|
||||
|
||||
public function Create()
|
||||
{
|
||||
parent::Create();
|
||||
|
||||
// Diese Eigenschaften werden vom Hauptmodul verwaltet und absichtlich
|
||||
// nicht im Formular angeboten. Die Childinstanz bleibt reine Anzeige.
|
||||
$this->RegisterPropertyInteger('ParentInstanceID', 0);
|
||||
$this->RegisterPropertyString('CounterKey', '');
|
||||
|
||||
$this->RegisterPropertyBoolean('ShowTotalEnergy', true);
|
||||
$this->RegisterPropertyBoolean('ShowTotalCost', true);
|
||||
$this->RegisterPropertyBoolean('ShowDayEnergy', true);
|
||||
$this->RegisterPropertyBoolean('ShowDayCost', true);
|
||||
$this->RegisterPropertyBoolean('ShowMonthEnergy', true);
|
||||
$this->RegisterPropertyBoolean('ShowMonthCost', true);
|
||||
|
||||
$this->EnsureProfiles();
|
||||
$this->RegisterValueVariables();
|
||||
}
|
||||
|
||||
public function ApplyChanges()
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
|
||||
$this->EnsureProfiles();
|
||||
$this->RegisterValueVariables();
|
||||
$this->ApplyVisibility();
|
||||
$this->SetStatus(102);
|
||||
}
|
||||
|
||||
private function RegisterValueVariables()
|
||||
{
|
||||
$this->RegisterVariableFloat('TotalEnergy', $this->Translate('Total Energy'), self::ENERGY_PROFILE, 10);
|
||||
$this->RegisterVariableFloat('TotalCost', $this->Translate('Total Cost'), self::COST_PROFILE, 20);
|
||||
$this->RegisterVariableFloat('DayEnergy', $this->Translate('Daily Energy'), self::ENERGY_PROFILE, 30);
|
||||
$this->RegisterVariableFloat('DayCost', $this->Translate('Daily Cost'), self::COST_PROFILE, 40);
|
||||
$this->RegisterVariableFloat('MonthEnergy', $this->Translate('Monthly Energy'), self::ENERGY_PROFILE, 50);
|
||||
$this->RegisterVariableFloat('MonthCost', $this->Translate('Monthly Cost'), self::COST_PROFILE, 60);
|
||||
}
|
||||
|
||||
private function ApplyVisibility()
|
||||
{
|
||||
$visibility = [
|
||||
'TotalEnergy' => $this->ReadPropertyBoolean('ShowTotalEnergy'),
|
||||
'TotalCost' => $this->ReadPropertyBoolean('ShowTotalCost'),
|
||||
'DayEnergy' => $this->ReadPropertyBoolean('ShowDayEnergy'),
|
||||
'DayCost' => $this->ReadPropertyBoolean('ShowDayCost'),
|
||||
'MonthEnergy' => $this->ReadPropertyBoolean('ShowMonthEnergy'),
|
||||
'MonthCost' => $this->ReadPropertyBoolean('ShowMonthCost')
|
||||
];
|
||||
|
||||
foreach ($visibility as $ident => $visible) {
|
||||
$variableID = $this->GetIDForIdent($ident);
|
||||
if ($variableID > 0) {
|
||||
IPS_SetHidden($variableID, !$visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function EnsureProfiles()
|
||||
{
|
||||
if (!IPS_VariableProfileExists(self::ENERGY_PROFILE)) {
|
||||
IPS_CreateVariableProfile(self::ENERGY_PROFILE, 2);
|
||||
IPS_SetVariableProfileText(self::ENERGY_PROFILE, '', ' kWh');
|
||||
IPS_SetVariableProfileDigits(self::ENERGY_PROFILE, 3);
|
||||
}
|
||||
|
||||
if (!IPS_VariableProfileExists(self::COST_PROFILE)) {
|
||||
IPS_CreateVariableProfile(self::COST_PROFILE, 2);
|
||||
IPS_SetVariableProfileText(self::COST_PROFILE, '', ' €');
|
||||
IPS_SetVariableProfileDigits(self::COST_PROFILE, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user