Habe das in Studio gemacht.
und so sieht dann das Skript aus.
<?php
/* =====================================================================================================
*
* IPSWorkflow Script
*
* Dieses Skript wurde von einem Workflow des IPSStudio erzeugt, bitte nehmen Sie keine Änderungen
* an dem Skript vor, da dieses beim nächsten Speichervorgang ansonsten wieder überschrieben werden.
*
* Generiert
* um: 01.10.2021 23:37:41
* von: IPSStudio
* ID: 23658
*
* Benutzte Objekte:
* 10520 - Zuhause - Strase.Fahrzeuge.Tesla Model S (HB IT 321E).Tesla Modul HB IT 321.TeslaVehicleControl
* 10418 - Zuhause - Strase.Fahrzeuge.Tesla Model S (HB IT 321E).Eigene Programmierung.Laden.Ladelimt
*
* Generierte Ereignisse:
* 57746 - Zuhause - Strase.Fahrzeuge.Tesla Model S (HB IT 321E).Eigene Programmierung.Laden.Ladelimit.Bei Änderung M4
*
* ===================================================================================================== */
$executionID = round(microtime(true)*1000)-(IPS_GetKernelStartTime()*1000);
SendDebug($_IPS['SELF'], 'S||||'.$executionID, '', 0);
$M3 = new IPSEntityInstance($_IPS, 10520, true);
$M1 = new IPSEntityVariable($_IPS, 10418, true, '', true);
$M2 = new IPSEntityModuleCvtValue2String($_IPS);
$M4 = new IPSEntityModuleOnChange($_IPS, 57746);
if ($M1->Evaluate()) {
SendDebug($_IPS['SELF'], 'M1|GetValue|M4|SetValue|'.$executionID,$M1->GetValue(),0);
$M4->SetValue($M1->GetValue());
}
if ($M4->Evaluate()) {
SendDebug($_IPS['SELF'], 'M4|GetValue|M2|SetValue|'.$executionID,$M4->GetValue(),0);
$M2->SetValue($M4->GetValue());
}
if ($M2->Evaluate()) {
SendDebug($_IPS['SELF'], 'M2|GetValue|M3|ChargeLimit|'.$executionID,$M2->GetValue(),0);
$M3->SetValue('ChargeLimit', $M2->GetValue());
}
$M3->Evaluate();
/* -----------------------------------------------------------------------*/
function SendDebug($id, $message, $data, $format) {
if (is_numeric($data)) {
$data = (string)round($data, 2);
} else if (is_string($data)) {
$data = '"'.$data.'"';
} else {}
IPS_SendDebug($id, $message, $data, $format);
}
/* -----------------------------------------------------------------------*/
function GetTypeConvertedValue($variableID, $value) {
$variableType = IPS_GetVariable($variableID)['VariableType'];
if ($variableType == 0) return (bool)$value;
else if ($variableType == 1) return (int)$value;
else if ($variableType == 2) return (float)$value;
else return $value;
}
/* -----------------------------------------------------------------------*/
class IPSEntityInstance {
private $ips;
private $id;
private $compareBeforUpdate;
public function __construct($ips, $id, $compareBeforUpdate) {
$this->ips = $ips;
$this->id = $id;
$this->compareBeforUpdate = $compareBeforUpdate;
}
private function GetTypeConvertedValue($ident, $value) {
return GetTypeConvertedValue(IPS_GetObjectIDByIdent($ident, $this->id), $value);
}
public function SetValue($ident, $value) {
if ($this->compareBeforUpdate && $this->GetValue($ident) === $this->GetTypeConvertedValue($ident, $value)) {
/* Value already equals to new Value !*/
} else {
RequestAction(IPS_GetObjectIDByIdent($ident, $this->id), $this->GetTypeConvertedValue($ident, $value));
}
}
public function GetValue($ident) {
return GetValue(IPS_GetObjectIDByIdent($ident, $this->id));
}
public function Evaluate() {
return true;
}
}
/* -----------------------------------------------------------------------*/
class IPSEntityVariable {
private $ips;
private $id;
private $value;
private $useActionScript;
private $compareBeforUpdate;
private $sender;
public function __construct($ips, $id, $useActionScript, $compareBeforUpdate, $sender) {
$this->ips = $ips;
$this->id = $id;
$this->useActionScript = $useActionScript;
$this->compareBeforUpdate = $compareBeforUpdate;
$this->sender = $sender;
}
public function SetValue($value) {
$variable = IPS_GetVariable($this->id);
$actionScriptID = $variable['VariableCustomAction'];
$scriptID = $this->ips['SELF'];
if ($this->compareBeforUpdate && $this->GetValue() === GetTypeConvertedValue($this->id, $value)) {
/* Value already equals to new Value !*/
} else if ($this->useActionScript && $actionScriptID > 10000 && $scriptID != $actionScriptID) {
RequestActionEx ($this->id, GetTypeConvertedValue($this->id, $value), $this->sender);
} else {
SetValue($this->id, GetTypeConvertedValue($this->id, $value));
}
}
public function GetValue() {
return GetValue($this->id);
}
public function Evaluate() {
return true;
}
}
/* -----------------------------------------------------------------------*/
class IPSEntityModuleCvtValue2String {
private $ips;
private $value;
private $callValue;
private $result;
public function __construct($ips) {
$this->ips = $ips;
$this->value = null;
$this->callValue = false;
$this->result = 0;
}
public function SetValue($value) {
$this->value = $value;
$this->callValue = true;
}
public function GetValue() {
return $this->result;
}
public function Evaluate() {
if (is_bool($this->value))
$this->result = $this->value ? 'true' : 'false';
else if (is_string($this->value))
$this->result = $this->value;
else
$this->result = strval($this->value);
return $this->callValue;
}
}
/* -----------------------------------------------------------------------*/
class IPSEntityModuleOnChange {
private $ips;
private $id;
private $value;
private $isFired;
public function __construct($ips, $id) {
$this->ips = $ips;
$this->id = $id;
}
public function Evaluate() {
$this->isFired = $this->ips['SENDER'] == 'Variable' && $this->ips['EVENT'] == $this->id;
return $this->isFired;
}
public function SetValue($value) {
$this->value = $value;
}
public function GetValue() {
return $this->value;
}
public function GetFired() {
return $this->isFired;
}
public function GetNotFired() {
return !$this->isFired;
}
}
SendDebug($_IPS['SELF'], 'F||||'.$executionID, '', 0);
?>
Und hier die Oberfläche dazu