Energiemanager optimiert, Easee-Ladestation eingefügt.

This commit is contained in:
2025-08-07 08:45:19 +02:00
parent 6ffada6d29
commit aa150f58be
18 changed files with 1347 additions and 232 deletions

View File

View File

@@ -0,0 +1,61 @@
{
"elements": [
{
"type": "ValidationTextBox",
"name": "broker_address",
"caption": "Broker-Adresse"
},
{
"type": "NumberSpinner",
"name": "broker_port",
"caption": "Broker-Port"
},
{
"type": "ValidationTextBox",
"name": "username",
"caption": "Benutzername"
},
{
"type": "PasswordTextBox",
"name": "password",
"caption": "Passwort"
},
{
"type": "ValidationTextBox",
"name": "Topic",
"caption": "MQTT Topic"
},
{
"type": "ValidationTextBox",
"name": "client_id",
"caption": "Klient Id"
},
{
"type": "ValidationTextBox",
"name": "mqtt_instance_id",
"caption": "MQTT Id"
},
{
"type": "NumberSpinner",
"name": "msg_id",
"caption": "Message ID"
},
{
"type": "ValidationTextBox",
"name": "src",
"caption": "Source"
},
{
"type": "ValidationTextBox",
"name": "method",
"caption": "Method"
},
{
"type": "SelectVariable",
"name": "switch_bool",
"caption": "Variable mit dem zu regelnden Shelly Kontakt",
"validVariableTypes": [0]
}
]
}

View File

@@ -0,0 +1,12 @@
{
"id": "{F6020D23-AA8C-34C5-D92F-9034BEFBBCD8}",
"name": "Symcon_Publish_to_Shelly_MQTT",
"type": 3,
"vendor": "Belevo AG",
"aliases": [],
"parentRequirements": [],
"childRequirements": [],
"implemented": [],
"prefix": "GEF",
"url": ""
}

View File

@@ -0,0 +1,90 @@
<?php
class Symcon_Publish_to_Shelly_MQTT extends IPSModule
{
public function Create()
{
parent::Create();
// MQTT-Verbindungsparameter als Properties
$this->RegisterPropertyString("broker_address", "");
$this->RegisterPropertyInteger("broker_port", 1883);
$this->RegisterPropertyString("username", "");
$this->RegisterPropertyString("password", "");
$this->RegisterPropertyString("Topic", "");
$this->RegisterPropertyString("client_id", "");
$this->RegisterPropertyInteger("mqtt_instance_id", 0);
// Nachricht-Payload-Parameter als Properties
$this->RegisterPropertyInteger("msg_id", 100);
$this->RegisterPropertyString("src", "user1");
$this->RegisterPropertyString("method", "Switch.Set");
$this->RegisterPropertyInteger("switch_bool", 0); // ID der Bool-Variable
$this->RegisterTimer("Timer_Influx",5000,"IPS_RequestAction(" . $this->InstanceID . ', "GetAction", "");');
}
public function ApplyChanges()
{
parent::ApplyChanges();
}
public function RequestAction($Ident, $Value)
{
IPS_LogMessage("ShellySwitchSender", "RequestAction gestartet");
switch ($Ident) {
case "GetAction":
$this->GetAction();
break;
default:
throw new Exception("Invalid action");
}
}
public function GetAction()
{
IPS_LogMessage("ShellySwitchSender", "GetAction gestartet");
$mqttInstanceID = $this->ReadPropertyInteger("mqtt_instance_id");
$topic = $this->ReadPropertyString("Topic");
$msg_id = $this->ReadPropertyInteger("msg_id");
$src = $this->ReadPropertyString("src");
$method = $this->ReadPropertyString("method");
$boolVarID = $this->ReadPropertyInteger("switch_bool");
if (!IPS_VariableExists($boolVarID)) {
IPS_LogMessage("ShellySwitchSender", "FEHLER: Bool-Variable mit ID $boolVarID existiert nicht.");
return;
}
$onValue = GetValueBoolean($boolVarID);
$payload = [
"id" => 0,
"src" => $src,
"method" => $method,
"params" => [
"id" => $msg_id,
"on" => $onValue
]
];
$jsonPayload = json_encode($payload);
IPS_LogMessage("ShellySwitchSender", "MQTT Payload: $jsonPayload");
if (!IPS_InstanceExists($mqttInstanceID)) {
IPS_LogMessage("ShellySwitchSender", "FEHLER: MQTT-Instanz-ID $mqttInstanceID existiert nicht.");
return;
}
// ✅ RICHTIG: Direkt senden über MQTTClient_SendMessage
MQTTClient_SendMessage($mqttInstanceID, $topic, $jsonPayload, 0, false);
IPS_LogMessage("ShellySwitchSender", "Nachricht erfolgreich gesendet");
}
}