@@ -3673,9 +3673,7 @@ private function registerVariable(mixed $feature, ?string $exposeType = null): v
36733673 }
36743674
36753675 // Zentrale EnableAction-Prüfung für State-Variablen
3676- if (isset ($ stateConfig ['enableAction ' ]) && $ stateConfig ['enableAction ' ]) {
3677- $ this ->checkAndEnableAction ($ stateConfig ['ident ' ], is_array ($ feature ) ? $ feature : null , true );
3678- }
3676+ $ this ->checkAndEnableAction ($ stateConfig ['ident ' ], is_array ($ feature ) ? $ feature : null );
36793677 return ;
36803678 }
36813679
@@ -4008,6 +4006,7 @@ private function registerSpecialVariable($feature): void
40084006 * Prüft und liefert die Konfiguration für State-basierte Features.
40094007 *
40104008 * Diese Methode analysiert ein Feature und bestimmt, ob es sich um ein State-Feature handelt.
4009+ *
40114010 * Sie prüft drei Szenarien:
40124011 * 1. Vordefinierte States aus stateDefinitions
40134012 * 2. Enum-Typ States (z.B. "state" mit definierten Werten)
@@ -4023,35 +4022,37 @@ private function registerSpecialVariable($feature): void
40234022 * - dataType: IPS Variablentyp (z.B. VARIABLETYPE_BOOLEAN, VARIABLETYPE_STRING)
40244023 * - values: Mögliche Zustände (z.B. ['ON', 'OFF'] oder ['OPEN', 'CLOSE', 'STOP'])
40254024 * - profile: Zu verwendenes IPS-Profil (z.B. '~Switch' oder 'Z2M.state.hash')
4026- * - enableAction: Ob Aktionen erlaubt sind (basierend auf access)
40274025 * - ident: Normalisierter Identifikator
40284026 *
40294027 * @param string $featureId Feature-Identifikator (z.B. 'state', 'state_left')
40304028 * @param array|null $feature Optionales Feature-Array mit weiteren Eigenschaften:
4031- * - access: Zugriffsrechte (0b010 für Schreibzugriff)
40324029 * - type: Datentyp ('enum', 'binary')
40334030 * - values: Array möglicher Enum-Werte
4031+ * Hinweis: Access-Rechte werden für EnableAction-Entscheidung
4032+ * an registerVariable() weitergegeben
40344033 *
40354034 * @return array|null Array mit State-Konfiguration oder null wenn kein State-Feature
40364035 *
40374036 * Beispiel:
40384037 * ```php
40394038 * // Standard boolean state
40404039 * $config = $this->getStateConfiguration('state');
4041- * // Ergebnis: ['type' => 'switch', 'dataType' => VARIABLETYPE_BOOLEAN, 'profile' => '~Switch', ... ]
4040+ * // Ergebnis: ['type' => 'switch', 'dataType' => VARIABLETYPE_BOOLEAN, 'profile' => '~Switch', 'ident' => 'state' ]
40424041 *
40434042 * // Enum state mit Profilerstellung
40444043 * $config = $this->getStateConfiguration('state', [
40454044 * 'type' => 'enum',
40464045 * 'values' => ['OPEN', 'CLOSE', 'STOP']
40474046 * ]);
4048- * // Ergebnis: ['type' => 'enum', 'dataType' => VARIABLETYPE_STRING, 'profile' => 'Z2M.state.hash', ... ]
4047+ * // Ergebnis: ['type' => 'enum', 'dataType' => VARIABLETYPE_STRING, 'profile' => 'Z2M.state.hash', 'ident' => 'state' ]
40494048 *
40504049 * // Vordefinierter state
40514050 * $config = $this->getStateConfiguration('valve_state');
4052- * // Ergebnis: Konfiguration aus stateDefinitions
4051+ * // Ergebnis: Konfiguration aus stateDefinitions (ohne enableAction)
40534052 * ```
40544053 *
4054+ * @see \Zigbee2MQTT\ModulBase::registerVariable() Verwendet die Konfiguration und trifft EnableAction-Entscheidung
4055+ * @see \Zigbee2MQTT\ModulBase::checkAndEnableAction() Zentrale EnableAction-Logik
40554056 * @see \IPSModule::SendDebug()
40564057 * @see preg_match()
40574058 */
@@ -4065,7 +4066,11 @@ private function getStateConfiguration(string $featureId, ?array $feature = null
40654066
40664067 // Prüfe ZUERST auf vordefinierte States
40674068 if (isset (static ::$ stateDefinitions [$ featureId ])) {
4068- return static ::$ stateDefinitions [$ featureId ];
4069+ $ stateConfig = static ::$ stateDefinitions [$ featureId ];
4070+ // Stelle sicher, dass ident und profile Keys existieren
4071+ $ stateConfig ['ident ' ] = $ stateConfig ['ident ' ] ?? $ featureId ;
4072+ $ stateConfig ['profile ' ] = $ stateConfig ['profile ' ] ?? '' ;
4073+ return $ stateConfig ;
40694074 }
40704075
40714076 // Dann auf enum type
@@ -4081,13 +4086,12 @@ private function getStateConfiguration(string $featureId, ?array $feature = null
40814086 // Profil anlegen
40824087 $ profileName = $ this ->registerEnumProfile ($ enumFeature , 'Z2M. ' . $ featureId );
40834088
4084- // Daten zur Variavblenregistrierung zurückgeben
4089+ // Daten zur Variablenregistrierung zurückgeben
40854090 return [
40864091 'type ' => 'enum ' ,
40874092 'dataType ' => VARIABLETYPE_STRING ,
40884093 'values ' => $ feature ['values ' ],
40894094 'profile ' => $ profileName ,
4090- 'enableAction ' => (isset ($ feature ['access ' ]) && ($ feature ['access ' ] & 0b010 ) != 0 ),
40914095 'ident ' => $ featureId
40924096 ];
40934097 }
@@ -4098,7 +4102,6 @@ private function getStateConfiguration(string $featureId, ?array $feature = null
40984102 'dataType ' => VARIABLETYPE_BOOLEAN ,
40994103 'values ' => ['ON ' , 'OFF ' ],
41004104 'profile ' => '~Switch ' ,
4101- 'enableAction ' => (isset ($ feature ['access ' ]) && ($ feature ['access ' ] & 0b010 ) != 0 ),
41024105 'ident ' => $ featureId
41034106 ];
41044107 }
@@ -4109,9 +4112,6 @@ private function getStateConfiguration(string $featureId, ?array $feature = null
41094112 // Stelle sicher, dass ident und profile Keys existieren
41104113 $ stateConfig ['ident ' ] = $ stateConfig ['ident ' ] ?? $ featureId ;
41114114 $ stateConfig ['profile ' ] = $ stateConfig ['profile ' ] ?? '' ;
4112- // EnableAction nur wenn explizit definiert oder access-Flag gesetzt
4113- $ stateConfig ['enableAction ' ] = $ stateConfig ['enableAction ' ] ??
4114- (isset ($ feature ['access ' ]) && ($ feature ['access ' ] & 0b010 ) != 0 );
41154115 return $ stateConfig ;
41164116 }
41174117
0 commit comments