Enhance Multialarmer: ensure LimitEn profile is created during initialization and apply changes

This commit is contained in:
jhartworks committed 2026-10-29 12:26:51 +01:00
1 parent 8c2f8244e6
commit 9ddef51789
1 file changed
+12
+12
View File
@@ -10,6 +10,7 @@ class Multialarmer extends IPSModule
{ {
parent::Create(); parent::Create();
$this->EnsureLimitEnProfile();
$this->RegisterProperties(); $this->RegisterProperties();
$this->RegisterRecipientVariables(); $this->RegisterRecipientVariables();
@@ -41,6 +42,8 @@ class Multialarmer extends IPSModule
public function ApplyChanges() public function ApplyChanges()
{ {
$this->EnsureLimitEnProfile();
// Ensure that existing Multialarmer instances also receive the // Ensure that existing Multialarmer instances also receive the
// recipient variables after the module update. // recipient variables after the module update.
$this->RegisterRecipientVariables(); $this->RegisterRecipientVariables();
@@ -136,6 +139,15 @@ class Multialarmer extends IPSModule
$this->RegisterPropertyString('WhatsAppApiKey', ''); $this->RegisterPropertyString('WhatsAppApiKey', '');
} }
private function EnsureLimitEnProfile()
{
if (!IPS_VariableProfileExists('LimitEn')) {
IPS_CreateVariableProfile('LimitEn', 0);
IPS_SetVariableProfileAssociation('LimitEn', true, 'Ja', '', 0x00FF00);
IPS_SetVariableProfileAssociation('LimitEn', false, 'Nein', '', 0xFFFF00);
}
}
private function RegisterRecipientVariables() private function RegisterRecipientVariables()
{ {
$mailRecipientsWereMissing = !@$this->GetIDForIdent('MailRecipients'); $mailRecipientsWereMissing = !@$this->GetIDForIdent('MailRecipients');