no message
This commit is contained in:
@@ -2,48 +2,12 @@
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "Label",
|
||||||
"caption": "MQTT Einstellungen"
|
"caption": "Dieses Modul lauscht auf MQTT-Nachrichten und erstellt pro Shelly-Gerät Variablen (input, output, temperature, online, type)."
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Select",
|
|
||||||
"name": "MQTTServer",
|
|
||||||
"caption": "MQTT Server",
|
|
||||||
"options": [
|
|
||||||
{
|
|
||||||
"caption": "Automatisch (Parent)",
|
|
||||||
"value": "auto"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CheckBox",
|
"type": "CheckBox",
|
||||||
"name": "Debug",
|
"name": "Debug",
|
||||||
"caption": "Debug Log aktivieren"
|
"caption": "Debug-Log aktivieren"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Label",
|
|
||||||
"caption": "Erkannte Shelly Geräte"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "List",
|
|
||||||
"name": "Devices",
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"caption": "Geräte-ID",
|
|
||||||
"name": "id",
|
|
||||||
"width": "200px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption": "Typ",
|
|
||||||
"name": "type",
|
|
||||||
"width": "150px"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Button",
|
|
||||||
"caption": "Geräte neu scannen",
|
|
||||||
"onClick": "ShellyScanDevices();"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"actions": []
|
"actions": []
|
||||||
|
|||||||
@@ -4,42 +4,80 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
class ShellyParser
|
class ShellyParser
|
||||||
{
|
{
|
||||||
/** Modell aus src extrahieren */
|
/**
|
||||||
|
* Extrahiert den Modell-Typ aus src, z.B.:
|
||||||
|
* "shelly1g4-12345" => "1g4"
|
||||||
|
* "shellyplusplugs-xyz" => "plusplugs"
|
||||||
|
*/
|
||||||
public static function ExtractType(string $src): string
|
public static function ExtractType(string $src): string
|
||||||
{
|
{
|
||||||
// Beispiel: "shelly1g4-12345"
|
if (!str_starts_with($src, 'shelly')) {
|
||||||
if (!str_starts_with($src, "shelly")) {
|
return 'unknown';
|
||||||
return "unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$str = substr($src, 6); // "1g4-12345"
|
// alles nach "shelly"
|
||||||
$parts = explode("-", $str); // ["1g4", "12345"]
|
$rest = substr($src, 6); // z.B. "1g4-12345" oder "plusplugs-xyz"
|
||||||
return $parts[0] ?? "unknown";
|
$parts = explode('-', $rest);
|
||||||
|
return $parts[0] ?? 'unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** generisches Mapping für Shelly Daten */
|
* Geht rekursiv durch params und sammelt bekannte Werte:
|
||||||
|
* - input (bool)
|
||||||
|
* - output (bool)
|
||||||
|
* - temperature (float, inkl. tC)
|
||||||
|
*/
|
||||||
public static function MapParams(array $params): array
|
public static function MapParams(array $params): array
|
||||||
{
|
{
|
||||||
$mapped = [];
|
$mapped = [
|
||||||
|
'input' => null,
|
||||||
|
'output' => null,
|
||||||
|
'temperature' => null
|
||||||
|
];
|
||||||
|
|
||||||
foreach ($params as $key => $val) {
|
self::ExtractRecursive($params, $mapped);
|
||||||
|
|
||||||
if ($key === "input") {
|
// null-Werte rauswerfen
|
||||||
$mapped["input"] = (bool)$val;
|
return array_filter($mapped, static function ($v) {
|
||||||
|
return $v !== null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key === "output") {
|
private static function ExtractRecursive(array $data, array &$mapped): void
|
||||||
$mapped["output"] = (bool)$val;
|
{
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
$lowerKey = strtolower((string)$key);
|
||||||
|
|
||||||
|
if (is_array($value)) {
|
||||||
|
// Temperatur in verschachtelter Struktur, z.B. ["temperature" => ["tC" => 41.2]]
|
||||||
|
if ($lowerKey === 'temperature') {
|
||||||
|
if (isset($value['tC']) && is_numeric($value['tC'])) {
|
||||||
|
$mapped['temperature'] = (float)$value['tC'];
|
||||||
|
} elseif (isset($value['t']) && is_numeric($value['t'])) {
|
||||||
|
$mapped['temperature'] = (float)$value['t'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self::ExtractRecursive($value, $mapped);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key === "temperature" || $key === "temp") {
|
switch ($lowerKey) {
|
||||||
$mapped["temperature"] = (float)$val;
|
case 'input':
|
||||||
}
|
$mapped['input'] = (bool)$value;
|
||||||
|
break;
|
||||||
|
|
||||||
// weitere Shelly-Geräte können später hier ergänzt werden
|
case 'output':
|
||||||
}
|
$mapped['output'] = (bool)$value;
|
||||||
|
break;
|
||||||
|
|
||||||
return $mapped;
|
case 'temperature':
|
||||||
|
case 'tc':
|
||||||
|
case 't':
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
$mapped['temperature'] = (float)$value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"id": "{CD0DFA85-F112-BD29-D304-8E5883C0EA79}",
|
"id": "{ED0ED0AC-3843-0888-DF27-FA45435BCEF3}",
|
||||||
"name": "Shelly_Parser_MQTT",
|
"name": "Shelly_Parser_MQTT",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"vendor": "Belevo AG",
|
"vendor": "Belevo",
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"Shelly_Parser_MQTT-Gateway"
|
"Shelly MQTT Parser"
|
||||||
],
|
],
|
||||||
"prefix": "Shelly_Parser_MQTT",
|
"prefix": "Shelly_Parser_MQTT",
|
||||||
"parentRequirements": [
|
"parentRequirements": [
|
||||||
@@ -13,5 +13,6 @@
|
|||||||
"childRequirements": [],
|
"childRequirements": [],
|
||||||
"implemented": [
|
"implemented": [
|
||||||
"{7F7632D9-FA40-4F38-8DEA-C83CD4325A32}"
|
"{7F7632D9-FA40-4F38-8DEA-C83CD4325A32}"
|
||||||
]
|
],
|
||||||
|
"version": "1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
require_once __DIR__ . "/libs/ShellyParser.php";
|
require_once __DIR__ . '/libs/ShellyParser.php';
|
||||||
|
|
||||||
class Shelly_Parser_MQTT extends IPSModule
|
class Shelly_Parser_MQTT extends IPSModule
|
||||||
{
|
{
|
||||||
@@ -10,213 +10,238 @@ class Shelly_Parser_MQTT extends IPSModule
|
|||||||
{
|
{
|
||||||
parent::Create();
|
parent::Create();
|
||||||
|
|
||||||
|
// Verbindung zum MQTT-Server herstellen
|
||||||
$this->ConnectParent('{C6D2AEB3-6E1F-4B2E-8E69-3A1A00246850}');
|
$this->ConnectParent('{C6D2AEB3-6E1F-4B2E-8E69-3A1A00246850}');
|
||||||
$this->Subscribe("#");
|
|
||||||
|
|
||||||
$this->RegisterPropertyString("Devices", "[]");
|
// Auf alle Topics lauschen, Filter machen wir selbst
|
||||||
$this->RegisterPropertyBoolean("Debug", false);
|
$this->Subscribe('#');
|
||||||
|
|
||||||
|
// Debug-Property
|
||||||
|
$this->RegisterPropertyBoolean('Debug', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function ApplyChanges()
|
public function ApplyChanges()
|
||||||
{
|
{
|
||||||
parent::ApplyChanges();
|
parent::ApplyChanges();
|
||||||
|
|
||||||
$this->ConnectParent('{C6D2AEB3-6E1F-4B2E-8E69-3A1A00246850}');
|
$this->ConnectParent('{C6D2AEB3-6E1F-4B2E-8E69-3A1A00246850}');
|
||||||
$this->Subscribe("#");
|
$this->Subscribe('#');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* MQTT SUBSCRIBE
|
* MQTT SUBSCRIBE
|
||||||
* ------------------------------------------------------------------*/
|
* ---------------------------------------------------------*/
|
||||||
private function Subscribe(string $topic)
|
private function Subscribe(string $topic): void
|
||||||
{
|
{
|
||||||
$packet = [
|
$packet = [
|
||||||
"PacketType" => 8,
|
'PacketType' => 8,
|
||||||
"QualityOfService" => 0,
|
'QualityOfService' => 0,
|
||||||
"Retain" => false,
|
'Retain' => false,
|
||||||
"Topic" => $topic,
|
'Topic' => $topic,
|
||||||
"Payload" => ""
|
'Payload' => ''
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->SendDataToParent(json_encode([
|
$this->SendDataToParent(json_encode([
|
||||||
"DataID" => "{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}"
|
'DataID' => '{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}'
|
||||||
] + $packet));
|
] + $packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* MQTT PUBLISH
|
* MQTT PUBLISH
|
||||||
* ------------------------------------------------------------------*/
|
* ---------------------------------------------------------*/
|
||||||
private function Publish(string $topic, string $payload)
|
private function Publish(string $topic, string $payload): void
|
||||||
{
|
{
|
||||||
$packet = [
|
$packet = [
|
||||||
"PacketType" => 3,
|
'PacketType' => 3,
|
||||||
"QualityOfService" => 0,
|
'QualityOfService' => 0,
|
||||||
"Retain" => false,
|
'Retain' => false,
|
||||||
"Topic" => $topic,
|
'Topic' => $topic,
|
||||||
"Payload" => $payload
|
'Payload' => $payload
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->SendDataToParent(json_encode([
|
$this->SendDataToParent(json_encode([
|
||||||
"DataID" => "{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}"
|
'DataID' => '{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}'
|
||||||
] + $packet));
|
] + $packet));
|
||||||
|
|
||||||
|
if ($this->ReadPropertyBoolean('Debug')) {
|
||||||
|
IPS_LogMessage('Shelly_Parser_MQTT', 'Publish: ' . $topic . ' -> ' . $payload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
/* ------------------------------------------------------------------
|
* RequestAction → Schalten von Outputs
|
||||||
* RequestAction → Schalten des Outputs
|
* ---------------------------------------------------------*/
|
||||||
* ------------------------------------------------------------------*/
|
|
||||||
public function RequestAction($Ident, $Value)
|
public function RequestAction($Ident, $Value)
|
||||||
{
|
{
|
||||||
$iid = IPS_GetParent($this->InstanceID);
|
// Wert lokal setzen
|
||||||
|
|
||||||
$this->SetValue($Ident, $Value);
|
$this->SetValue($Ident, $Value);
|
||||||
|
|
||||||
// output?
|
// Wir erwarten Ident im Format: "<DeviceID>_output"
|
||||||
if ($Ident === "output") {
|
if (str_ends_with($Ident, '_output')) {
|
||||||
|
$deviceID = substr($Ident, 0, -strlen('_output'));
|
||||||
|
|
||||||
$deviceID = IPS_GetName($iid);
|
$topic = $deviceID . '/rpc/Switch.Set';
|
||||||
|
|
||||||
$topic = $deviceID . "/rpc/Switch.Set";
|
|
||||||
$payload = json_encode([
|
$payload = json_encode([
|
||||||
"id" => 0,
|
'id' => 0,
|
||||||
"on" => (bool)$Value
|
'on' => (bool)$Value
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->Publish($topic, $payload);
|
$this->Publish($topic, $payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
/* ------------------------------------------------------------------
|
* RECEIVE MQTT DATA
|
||||||
* RECEIVE MQTT
|
* ---------------------------------------------------------*/
|
||||||
* ------------------------------------------------------------------*/
|
|
||||||
public function ReceiveData($JSONString)
|
public function ReceiveData($JSONString)
|
||||||
{
|
{
|
||||||
|
if ($this->ReadPropertyBoolean('Debug')) {
|
||||||
|
IPS_LogMessage('Shelly_Parser_MQTT', 'ReceiveData: ' . $JSONString);
|
||||||
|
}
|
||||||
|
|
||||||
$data = json_decode($JSONString, true);
|
$data = json_decode($JSONString, true);
|
||||||
|
if (!is_array($data)) {
|
||||||
$topic = $data["Topic"] ?? "";
|
|
||||||
$payload = $data["Payload"] ?? "";
|
|
||||||
|
|
||||||
if ($topic === "") {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = explode("/", $topic);
|
$topic = $data['Topic'] ?? '';
|
||||||
$deviceID = $parts[0] ?? "";
|
$payload = $data['Payload'] ?? '';
|
||||||
|
|
||||||
if ($deviceID === "") {
|
if ($topic === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ONLINE
|
$parts = explode('/', $topic);
|
||||||
if (isset($parts[1]) && $parts[1] === "online") {
|
$deviceID = $parts[0] ?? '';
|
||||||
|
|
||||||
|
if ($deviceID === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <GeräteID>/online
|
||||||
|
if ((isset($parts[1])) && ($parts[1] === 'online')) {
|
||||||
$this->HandleOnline($deviceID, $payload);
|
$this->HandleOnline($deviceID, $payload);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RPC
|
// <GeräteID>/events/rpc
|
||||||
if ((($parts[1] ?? "") === "events") && (($parts[2] ?? "") === "rpc")) {
|
if ((isset($parts[1]) && $parts[1] === 'events') &&
|
||||||
|
(isset($parts[2]) && $parts[2] === 'rpc')) {
|
||||||
$this->HandleRPC($deviceID, $payload);
|
$this->HandleRPC($deviceID, $payload);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
/* ------------------------------------------------------------------
|
* ONLINE-STATUS
|
||||||
* ONLINE
|
* ---------------------------------------------------------*/
|
||||||
* ------------------------------------------------------------------*/
|
private function HandleOnline(string $deviceID, string $payload): void
|
||||||
private function HandleOnline(string $deviceID, string $payload)
|
|
||||||
{
|
{
|
||||||
$iid = $this->GetOrCreateDeviceInstance($deviceID);
|
$ident = $deviceID . '_online';
|
||||||
|
$name = $deviceID . ' Online';
|
||||||
|
|
||||||
$onlineID = @$this->GetIDForIdentEx("online", $iid);
|
$this->EnsureBooleanVariable($ident, $name);
|
||||||
if (!$onlineID) {
|
|
||||||
$this->RegisterVariableBoolean("online", "Online");
|
$value = ($payload === 'true' || $payload === '1');
|
||||||
|
$this->SetValue($ident, $value);
|
||||||
|
|
||||||
|
if ($this->ReadPropertyBoolean('Debug')) {
|
||||||
|
IPS_LogMessage('Shelly_Parser_MQTT', sprintf(
|
||||||
|
'Online-Status %s -> %s',
|
||||||
|
$deviceID,
|
||||||
|
$value ? 'true' : 'false'
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->SetValue("online", $payload === "true");
|
/* ---------------------------------------------------------
|
||||||
}
|
* RPC-EVENTS
|
||||||
|
* ---------------------------------------------------------*/
|
||||||
|
private function HandleRPC(string $deviceID, string $payload): void
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* RPC
|
|
||||||
* ------------------------------------------------------------------*/
|
|
||||||
private function HandleRPC(string $deviceID, string $payload)
|
|
||||||
{
|
{
|
||||||
$json = json_decode($payload, true);
|
$json = json_decode($payload, true);
|
||||||
if (!is_array($json)) {
|
if (!is_array($json)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$src = $json["src"] ?? "";
|
$src = $json['src'] ?? '';
|
||||||
if (!str_starts_with($src, "shelly")) {
|
if (!is_string($src) || !str_starts_with($src, 'shelly')) {
|
||||||
|
// kein Shelly-Gerät → ignorieren
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modell ermitteln
|
// Typ/Modell aus src extrahieren
|
||||||
$type = ShellyParser::ExtractType($src);
|
$type = ShellyParser::ExtractType($src);
|
||||||
|
|
||||||
$iid = $this->GetOrCreateDeviceInstance($deviceID);
|
// Typ-Variable
|
||||||
|
$typeIdent = $deviceID . '_type';
|
||||||
|
$this->EnsureStringVariable($typeIdent, $deviceID . ' Typ');
|
||||||
|
$this->SetValue($typeIdent, $type);
|
||||||
|
|
||||||
// Typ speichern
|
// params parsen
|
||||||
$this->RegisterVariableString("type", "Geräte-Typ");
|
$params = $json['params'] ?? [];
|
||||||
$this->SetValue("type", $type);
|
if (!is_array($params)) {
|
||||||
|
return;
|
||||||
// Parameter extrahieren
|
|
||||||
$mapped = ShellyParser::MapParams($json["params"] ?? []);
|
|
||||||
|
|
||||||
// Variablen anlegen
|
|
||||||
if (isset($mapped["input"])) {
|
|
||||||
$this->RegisterVariableBoolean("input", "Input");
|
|
||||||
$this->SetValue("input", $mapped["input"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($mapped["output"])) {
|
$mapped = ShellyParser::MapParams($params);
|
||||||
$this->RegisterVariableBoolean("output", "Output");
|
|
||||||
$this->EnableAction("output");
|
// input
|
||||||
$this->SetValue("output", $mapped["output"]);
|
if (array_key_exists('input', $mapped)) {
|
||||||
|
$ident = $deviceID . '_input';
|
||||||
|
$this->EnsureBooleanVariable($ident, $deviceID . ' Input');
|
||||||
|
$this->SetValue($ident, (bool)$mapped['input']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($mapped["temperature"])) {
|
// output
|
||||||
$this->RegisterVariableFloat("temperature", "Temperatur");
|
if (array_key_exists('output', $mapped)) {
|
||||||
$this->SetValue("temperature", $mapped["temperature"]);
|
$ident = $deviceID . '_output';
|
||||||
|
$this->EnsureBooleanVariable($ident, $deviceID . ' Output');
|
||||||
|
$this->EnableAction($ident);
|
||||||
|
$this->SetValue($ident, (bool)$mapped['output']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// temperature
|
||||||
|
if (array_key_exists('temperature', $mapped)) {
|
||||||
|
$ident = $deviceID . '_temperature';
|
||||||
|
$this->EnsureFloatVariable($ident, $deviceID . ' Temperatur');
|
||||||
|
$this->SetValue($ident, (float)$mapped['temperature']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->ReadPropertyBoolean('Debug')) {
|
||||||
|
IPS_LogMessage('Shelly_Parser_MQTT', sprintf(
|
||||||
|
'RPC von %s (Typ %s) → %s',
|
||||||
|
$deviceID,
|
||||||
|
$type,
|
||||||
|
json_encode($mapped)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ShellyScanDevices()
|
/* ---------------------------------------------------------
|
||||||
|
* Helper für Variablen
|
||||||
|
* ---------------------------------------------------------*/
|
||||||
|
private function EnsureBooleanVariable(string $ident, string $name): void
|
||||||
{
|
{
|
||||||
// Diese Funktion kann später echte Scan-Logik erhalten.
|
$id = @$this->GetIDForIdent($ident);
|
||||||
// Jetzt nur Dummy, damit das Modul geladen wird.
|
if ($id === false) {
|
||||||
IPS_LogMessage("Shelly_Parser_MQTT", "ShellyScanDevices() aufgerufen");
|
$this->RegisterVariableBoolean($ident, $name);
|
||||||
|
|
||||||
// Optional: spätere Erweiterung – bekannte Devices ausgeben
|
|
||||||
$devices = json_decode($this->ReadPropertyString("Devices"), true);
|
|
||||||
if (is_array($devices)) {
|
|
||||||
IPS_LogMessage("Shelly_Parser_MQTT", "Aktuell gespeicherte Geräte: " . json_encode($devices));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function EnsureFloatVariable(string $ident, string $name): void
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
* Helper → Child-Instanzen erzeugen
|
|
||||||
* ------------------------------------------------------------------*/
|
|
||||||
private function GetOrCreateDeviceInstance(string $deviceID)
|
|
||||||
{
|
{
|
||||||
foreach (IPS_GetInstanceListByModuleID("{ED0ED0AC-3843-0888-DF27-FA45435BCEF3}") as $id) {
|
$id = @$this->GetIDForIdent($ident);
|
||||||
if (IPS_GetName($id) === $deviceID) {
|
if ($id === false) {
|
||||||
return $id;
|
$this->RegisterVariableFloat($ident, $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// neue Instanz
|
private function EnsureStringVariable(string $ident, string $name): void
|
||||||
$iid = IPS_CreateInstance("{ED0ED0AC-3843-0888-DF27-FA45435BCEF3}");
|
{
|
||||||
IPS_SetName($iid, $deviceID);
|
$id = @$this->GetIDForIdent($ident);
|
||||||
IPS_SetParent($iid, $this->InstanceID);
|
if ($id === false) {
|
||||||
|
$this->RegisterVariableString($ident, $name);
|
||||||
return $iid;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user