Hallo,
Ich entwickele gerade ein Modul für Osram Lightify. Dabei stoße ich auf folgendes Problem:
Die Modulbibliothek hat zwei Module (LFYLight und LFYGroup), deren Klasse beide von der selben Basisklasse (LFYDevice) abgeleitet sind:
require_once(__DIR__ . "/../LFYDevice.php");
class LFYLight extends LFYDevice {
public function Create() {
parent::Create();
$this->RegisterPropertyString("UniqueId", "");
$this->RegisterPropertyInteger("LightId", 0);
$this->RegisterPropertyString("Type", "");
$this->RegisterPropertyInteger("LightFeatures", 0); // a combination of 1-onOff, 2-Level, 4-Color, 8-Temperatur
$this->RegisterPropertyString("ModelName", "");
$this->RegisterPropertyString("Manufacturer", "");
$this->RegisterPropertyString("FirmwareVersion", "");
}
protected function BasePath() {
$id = $this->ReadPropertyInteger("LightId");
return "devices/$id";
}
}
require_once(__DIR__ . "/../LFYDevice.php");
class LFYGroup extends LFYDevice {
public function Create() {
parent::Create();
$this->RegisterPropertyInteger("GroupId", 0);
$this->RegisterPropertyInteger("LightFeatures", 0); // a combination of 1-onOff, 2-Level, 4-Color, 8-Temperatur
}
protected function BasePath() {
$id = $this->ReadPropertyInteger("GroupId");
return "/groups/$id";
}
}
abstract class LFYDevice extends IPSModule {
public function __construct($InstanceID) {
parent::__construct($InstanceID);
IPS_LogMessage(get_class($this), 'InstanceID: '.$InstanceID.', ModuleName: '.IPS_GetInstance($InstanceID)['ModuleInfo']['ModuleName'].', Class: '.get_class($this).', ParentClass: '.get_parent_class($this));
}
Wenn ich in der jeweiligen Modul.json beiden das gleiche Prefix gebe (‚LFY‘), dann werden die Instanzen offensichtlich falsch instanziiert. Im Logfile sieht man dann folgende Einträge:
16:07:10 | 00000 | CUSTOM | LFYGroup | InstanceID: 19836, ModuleName: LFYLight, Class: LFYGroup, ParentClass: LFYDevice
16:07:10 | 00000 | CUSTOM | LFYGroup | InstanceID: 12044, ModuleName: LFYLight, Class: LFYGroup, ParentClass: LFYDevice
16:07:10 | 00000 | CUSTOM | LFYGroup | InstanceID: 50060, ModuleName: LFYLight, Class: LFYGroup, ParentClass: LFYDevice
16:07:10 | 00000 | CUSTOM | LFYGroup | InstanceID: 46120, ModuleName: LFYGroup, Class: LFYGroup, ParentClass: LFYDevice
16:07:10 | 00000 | CUSTOM | LFYGroup | InstanceID: 12121, ModuleName: LFYGroup, Class: LFYGroup, ParentClass: LFYDevice
16:07:10 | 00000 | CUSTOM | LFYGroup | InstanceID: 24337, ModuleName: LFYGroup, Class: LFYGroup, ParentClass: LFYDevice
Vergebe ich jedoch unterschiedliche Prefixe (‚LFY‘ und ‚LFYGroup‘), dann werden die Instanzen richtig instanziiert:
16:14:05 | 00000 | CUSTOM | LFYLight | InstanceID: 45763, ModuleName: LFYLight, Class: LFYLight, ParentClass: LFYDevice
16:14:05 | 00000 | CUSTOM | LFYLight | InstanceID: 12044, ModuleName: LFYLight, Class: LFYLight, ParentClass: LFYDevice
16:14:05 | 00000 | CUSTOM | LFYLight | InstanceID: 50060, ModuleName: LFYLight, Class: LFYLight, ParentClass: LFYDevice
16:14:05 | 00000 | CUSTOM | LFYGroup | InstanceID: 20999, ModuleName: LFYGroup, Class: LFYGroup, ParentClass: LFYDevice
16:14:05 | 00000 | CUSTOM | LFYGroup | InstanceID: 48484, ModuleName: LFYGroup, Class: LFYGroup, ParentClass: LFYDevice
16:14:05 | 00000 | CUSTOM | LFYGroup | InstanceID: 24337, ModuleName: LFYGroup, Class: LFYGroup, ParentClass: LFYDevice
Gibt es da eine Erklärung für? Ich möchte gerne den gleichen Präfix verwenden, um nicht die sichtbaren Funktionen unnötig zu verdoppeln.
Gruß
Burkhard
Modules.zip (3.53 KB)