Ich habe einmal soweit ich konnte die Vorgabe Deines Profils angepasst und habe nun noch die
Laufzeit sowie TeachIn/TeachOut offen.
Da komme ich nicht weiter, aber der Anfang des Scriptes könnte funktionieren.
Vielleicht schaust Du mal drüber ob das so klappen kann.
MfG
Ingo
<?php
class mEnOceanFEEPA53808_7 extends IPSModule
{
public function Create()
{
//Never delete this line!
parent::Create();
$this->RegisterPropertyString(„ReturnID“, „00000000“);
$this->RegisterPropertyString("BaseData", '{
"DataID":"{70E3075F-A35D-4DEB-AC20-C929A156FE48}",
"Device":165, //Telegram Type RPS/1BS/4BS/VLD etc.
"Status":0,
"DeviceID":0,
"DestinationID":-1,
"DataLength":4,
"DataByte12":0,
"DataByte11":0,
"DataByte10":0,
"DataByte9":0,
"DataByte8":0,
"DataByte7":0,
"DataByte6":0,
"DataByte5":0,
"DataByte4":0,
"DataByte3":0,
"DataByte2":0,
"DataByte1":0,
"DataByte0":0
}');
//Connect to available enocean gateway
$this->ConnectParent("{A52FEFE9-7858-4B8E-A96E-26E15CB944F7}");
}
public function Destroy(){
//Never delete this line!
parent::Destroy();
}
public function ApplyChanges()
{
//Never delete this line!
parent::ApplyChanges();
$this->RegisterVariableInteger('Position', $this->Translate('Position'), "~Blinds");
Filter setzen
$this->SetReceiveDataFilter(".*"DeviceID":".(int)hexdec($this->ReadPropertyString("ReturnID")).",.*");
Slider für Position aktivieren
$this->EnableAction("Position");
}
public function ReceiveData($JSONString)
{
$this->SendDebug("Received", $JSONString, 0);
$data = json_decode($JSONString);
switch($data->Device) {
case "165": // 4BS
$position = $data->DataByte2;
$this->SendDebug("Received Position", $position."%", 0);
SetValue($this->GetIDForIdent("Position"), $position);
break;
default:
$this->LogMessage("Unknown Message", KL_ERROR);
}
}
public function RequestAction($Ident, $Value)
{
switch($Ident) {
case "Position":
$this->ShutterMoveTo($Value);
break;
default:
throw new Exception("Invalid Ident");
}
}
public function ShutterMoveTo(int $position)
{
$data = json_decode($this->ReadPropertyString("BaseData"));
$data->DataByte0 = 72; // DB0 Bit 1 Pos.Value avail Bit6 (Val 4) Drive to.. DB2 Pos.Val DB0.3 = 1 Data Telegram
$data->DataByte2 = $position;
$data->DestinationID = (int)hexdec($this->ReadPropertyString("ReturnID"));
$this->SendData(json_encode($data));
}
public function ShutterStop()
{
$data = json_decode($this->ReadPropertyString("BaseData"));
$data->DataLength= 1;
$data->DataByte0 = 10; // Set Func Stop DB0.4 = 1
$data->DestinationID = (int)hexdec($this->ReadPropertyString("ReturnID"));
$this->SendData(json_encode($data));
}
public function ShutterMoveDown()
{
$this->ShutterMoveTo(100);
}
public function ShutterMoveUp()
{
$this->ShutterMoveTo(0);
}
public function UpdatePosition()
{
$data = json_decode($this->ReadPropertyString("BaseData"));
$data->DataLength= 1;
$data->DataByte0 = 8; // DB0.3 = 2 Data Telegram DB 0.4-7 = 0 Status request
$data->DestinationID = (int)hexdec($this->ReadPropertyString("ReturnID"));
$this->SendData(json_encode($data));
}
public function SetRunTime(int $milliseconds)
{
$milliseconds = (int)($milliseconds/10);
if($milliseconds < 500 || $milliseconds >32767) $milliseconds = 32767;
$data = json_decode($this->ReadPropertyString("BaseData"));
$data->DataLength= 5;
$data->DataByte0 = 5;
$data->DataByte1 = 7;
$data->DataByte3 = $milliseconds%256;
$data->DataByte4 = (int)($milliseconds/256);
$data->DestinationID = (int)hexdec($this->ReadPropertyString("ReturnID"));
$this->SendData(json_encode($data));
}
public function TeachIn()
{
$data = json_decode($this->ReadPropertyString("BaseData"));
$data->Device = 165, //Telegram Type RPS/1BS/4BS/VLD etc.
$data->DataLength = 4; // 4BS = 4Byte ????
$data->DataByte0 = 8;
$data->DataByte1 = 5;
$data->DataByte2 = 0;
$data->DataByte3 = 0;
$data->DataByte4 = 70;
$data->DataByte5 = 1;
$data->DataByte6 = 145;
$data->DestinationID = (int)hexdec($this->ReadPropertyString("ReturnID"));
$this->SendData(json_encode($data));
}
public function TeachOut()
{
$data = json_decode($this->ReadPropertyString("BaseData"));
$data->Device = 165, //Telegram Type RPS/1BS/4BS/VLD etc.
$data->DataLength = 4; // 4BS = 4Byte ????
$data->DataByte0 = 210;
$data->DataByte1 = 5;
$data->DataByte2 = 0;
$data->DataByte3 = 0;
$data->DataByte4 = 70;
$data->DataByte5 = 1;
$data->DataByte6 = 161;
$data->DestinationID = (int)hexdec($this->ReadPropertyString("ReturnID"));
$this->SendData(json_encode($data));
}
protected function SendData($data)
{
$this->SendDataToParent($data);
$this->SendDebug("Sended", $data, 0);
}
protected function SendDebug($Message, $Data, $Format)
{
if (is_array($Data))
{
foreach ($Data as $Key => $DebugData)
{
$this->SendDebug($Message . ":" . $Key, $DebugData, 0);
}
}
else if (is_object($Data))
{
foreach ($Data as $Key => $DebugData)
{
$this->SendDebug($Message . "." . $Key, $DebugData, 0);
}
}
else
{
parent::SendDebug($Message, $Data, $Format);
}
}
}