Hi also mal zu den Gegebenheiten, steuere meine Rollos (LCN) über das Shutter Modul klappt soweit ganz gut, da ich nicht auf die einzelne Visualisierung verzichten möchte und LCN ned so wirklich im Shadowing realisiert bekommen habe möchte ich, die Shuttermodul Instanzen in das Shadowing Script einbauen…
Nutze diesen Code:
<?
//Variables provided by ShutterControl Module
//IPS_LogMessage("InstanceID", $SC_INSTANCE); /* InstanceID */
//IPS_LogMessage("Direction", $SC_DIRECTION); /* {0..2} Stop, Up, Down */
//IPS_LogMessage("Duration", $SC_DURATION); /* ms */
switch($IPS_SENDER)
{
case "ShutterControl": //Script wurde vom Shuttermodul aufgerufen
define("SC_DIRECTION_STOP", 0);
define("SC_DIRECTION_UP", 1);
define("SC_DIRECTION_DOWN", 2);
$instance = IPS_GetInstance($SC_INSTANCE);
switch($instance['ModuleInfo']['ModuleID'])
{
case "{48FCFDC1-11A5-4309-BB0B-A0DB8042A969}": //FS20
$running = CreateVariableByName($SC_INSTANCE, "Moving", 0);
$value = GetValue(IPS_GetStatusVariableID($SC_INSTANCE, "StatusVariable"));
switch($SC_DIRECTION)
{
case SC_DIRECTION_STOP:
if(GetValue($running))
{
FS20_SwitchMode($SC_INSTANCE, $value);
SetValue($running, false);
}
break;
case SC_DIRECTION_UP:
if(!GetValue($running))
{
FS20_SwitchMode($SC_INSTANCE, true);
SetValue($running, true);
}
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "FS20U");
}
if($SC_DURATION > 0 and $SC_DURATION <=999)
{
IPS_Sleep($SC_DURATION);
FS20_SwitchMode($SC_INSTANCE, true);
SetValue($running, false);
}
break;
case SC_DIRECTION_DOWN:
if(!GetValue($running))
{
FS20_SwitchMode($SC_INSTANCE, false);
SetValue($running, true);
}
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "FS20D");
}
if($SC_DURATION > 0 and $SC_DURATION <=999)
{
IPS_Sleep($SC_DURATION);
FS20_SwitchMode($SC_INSTANCE, false);
SetValue($running, false);
}
break;
}
break;
case "{1B7B5B7D-CAA9-4AB5-B9D8-EC805EC955AD}": //xComfort
switch($SC_DIRECTION)
{
case SC_DIRECTION_STOP:
MXC_ShutterStop($SC_INSTANCE);
break;
case SC_DIRECTION_UP:
MXC_ShutterMoveUp($SC_INSTANCE);
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "XCOM");
}
if($SC_DURATION > 0 and $SC_DURATION <= 999)
{
IPS_Sleep($SC_DURATION);
MXC_ShutterStop($SC_INSTANCE);
}
break;
case SC_DIRECTION_DOWN:
MXC_ShutterMoveDown($SC_INSTANCE);
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "XCOM");
}
if($SC_DURATION > 0 and $SC_DURATION <= 999)
{
IPS_Sleep($SC_DURATION);
MXC_ShutterStop($SC_INSTANCE);
}
break;
}
break;
case "{2D871359-14D8-493F-9B01-26432E3A710F}": //LCN
$type=LCN_GetUnit($SC_INSTANCE);
switch($type)
{
case 0: //Ausgänge
switch($SC_DIRECTION)
{
case SC_DIRECTION_STOP:
LCN_SetIntensity($SC_INSTANCE,0,0);
LCN_SetIntensity($SC_INSTANCE2,0,0);
break;
case SC_DIRECTION_UP:
LCN_SetIntensity($SC_INSTANCE,100,4);
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "LCNA");
}
if($SC_DURATION > 0 and $SC_DURATION <= 999)
{
IPS_Sleep($SC_DURATION);
LCN_SetIntensity($SC_INSTANCE,0,0);
}
break;
case SC_DIRECTION_DOWN:
LCN_SetIntensity($SC_INSTANCE2,100,4);
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE2, $SC_DURATION, "LCNA");
}
if($SC_DURATION > 0 and $SC_DURATION <= 999)
{
IPS_Sleep($SC_DURATION);
LCN_SetIntensity($SC_INSTANCE2,0,0);
}
break;
}
break;
case 2: //Relais
switch($SC_DIRECTION)
{
case SC_DIRECTION_STOP:
LCN_SwitchRelay($SC_INSTANCE,false);
break;
case SC_DIRECTION_UP:
LCN_SwitchRelay($SC_INSTANCE,true);
LCN_SwitchRelay($SC_INSTANCE2,false); // Um Relaisrichtung zu ändern bitte auf true
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "LCNR");
}
if($SC_DURATION > 0 and $SC_DURATION <= 999)
{
IPS_Sleep($SC_DURATION);
LCN_SwitchRelay($SC_INSTANCE, false);
}
break;
case SC_DIRECTION_DOWN:
LCN_SwitchRelay($SC_INSTANCE,true);
LCN_SwitchRelay($SC_INSTANCE2,true);// Um Relaisrichtung zu ändern bitte auf false
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "LCNR");
}
if($SC_DURATION > 0 and $SC_DURATION <= 999)
{
IPS_Sleep($SC_DURATION);
LCN_SwitchRelay($SC_INSTANCE, false);
}
break;
}
break;
}
break;
case "{9317CC5B-4E1D-4440-AF3A-5CC7FB42CCAA}": //1-Wire Shutter
switch($SC_DIRECTION)
{
case SC_DIRECTION_STOP:
OneWireShutter($SC_INSTANCE, 0, $SC_DURATION);
break;
case SC_DIRECTION_UP:
if($SC_DURATION == 0)
$SC_DURATION = 120000;
OneWireShutter($SC_INSTANCE, 0, $SC_DURATION);
break;
case SC_DIRECTION_DOWN:
if($SC_DURATION == 0)
$SC_DURATION = 120000;
OneWireShutter($SC_INSTANCE, 1, $SC_DURATION);
break;
}
break;
case "{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}": //Homematic Shutter
switch($SC_DIRECTION)
{
case SC_DIRECTION_STOP:
HM_WriteValueBoolean($SC_INSTANCE, "STOP", true);
break;
case SC_DIRECTION_UP:
HM_WriteValueFloat($SC_INSTANCE, "LEVEL", 1.0);
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "HOME");
}
if($SC_DURATION > 0 and $SC_DURATION <=999)
{
IPS_Sleep($SC_DURATION);
HM_WriteValueBoolean($SC_INSTANCE, "STOP", true);
}
break;
case SC_DIRECTION_DOWN:
HM_WriteValueFloat($SC_INSTANCE, "LEVEL", 0.0);
if($SC_DURATION > 999)
{
TimerDelay($SC_INSTANCE, $SC_DURATION, "HOME");
}
if($SC_DURATION > 0 and $SC_DURATION <=999)
{
IPS_Sleep($SC_DURATION);
HM_WriteValueBoolean($SC_INSTANCE, "STOP", true);
}
break;
}
break;
default:
die("No Handler for Module ".$instance['ModuleInfo']['ModuleName']." found");
}
break;
case "TimerEvent": //Script wurde von einem Ereignis aufgerufen
IPS_SetEventActive($IPS_EVENT, false); //Ereignis deaktivieren
$timer=IPS_GetName($IPS_EVENT);
$SCT_INSTANCE = intval(substr($timer,-5,5));
$bus = substr($timer,0,-5);
switch ($bus)
{
case "LCNA":
LCN_SetIntensity($SCT_INSTANCE,0,0);
break;
case "LCNR":
LCN_SwitchRelay($SCT_INSTANCE,false);
break;
case "XCOM":
MXC_ShutterStop($SCT_INSTANCE);
break;
case "HOME":
HM_WriteValueBoolean($SCT_INSTANCE, "STOP", true);
break;
case "FS20U":
$running = CreateVariableByName($SCT_INSTANCE, "Moving", 0);
FS20_SwitchMode($SCT_INSTANCE, true);
SetValue($running, false);
break;
case "FS20D":
$running = CreateVariableByName($SCT_INSTANCE, "Moving", 0);
FS20_SwitchMode($SCT_INSTANCE, false);
SetValue($running, false);
break;
}
break;
}
function OneWireShutter($ins, $dir, $sec) {
@TMEX_F29_SetStrobe($ins, True);
$res = ($dir * 128) + ($sec / 1000);
@TMEX_F29_SetPort((integer)$ins, (integer)$res);
}
function TimerDelay($id, $time, $bus) {
global $IPS_SELF;
$sekunden=intval(substr($time, 0,-3));
$msekunden=substr($time, -3, 3);
$timerid = IPS_GetObjectIDByName($bus.$id, $IPS_SELF);
if ($timerid ==0)
{
$newtimer = IPS_CreateEvent(1);
// IPS_SetEventScript($newtimer, $IPS_SELF); //alt Aktuelles Skript aufrufen
IPS_SetParent($newtimer, $IPS_SELF); //ab V2_1 Aktuelles Skript aufrufen
IPS_SetName($newtimer, $bus.$id);
IPS_Sleep(intval($msekunden));
IPS_SetEventCyclic($newtimer, 0, 0, 0, 0, 1, $sekunden);
IPS_SetEventCyclicDateBounds($newtimer, 0, 0);
IPS_SetEventCyclicTimeBounds($newtimer, time(), 0);
IPS_SetEventActive($newtimer, true); //Ereignis aktivieren
}
else
{
IPS_Sleep(intval($msekunden));
IPS_SetEventCyclic($timerid, 0, 0, 0, 0, 1, $sekunden);
IPS_SetEventCyclicDateBounds($timerid, 0, 0);
IPS_SetEventCyclicTimeBounds($timerid, time(), 0);
IPS_SetEventActive($timerid, true); //Ereignis aktivieren
}
}
function CreateVariableByName($id, $name, $type)
{
global $IPS_SELF;
$vid = @IPS_GetVariableIDByName($name, $id);
if($vid===false) {
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetInfo($vid, "This Variable was created by Script #$IPS_SELF");
}
return $vid;
}
?>
Da der aus der Doku bei mir nicht funzt sondern immer nur ausgibt das er nur mit dem Modul Ausführbar ist was ich jedoch versuche naja…
Aber nun zu meinem Problem:
Habe ein Velux Dachfenster mit elektrischen Rollo, welches ich über das VeluxInterface steuere. Wer das Velux Interface kennt weiß es handelt sich um eine One Touch Bedienung, d.h.
einmal Relais betätigen z.B für 0,3 s Runter
nochmal Relais betätigen STOP
nochmal Relais betätigen Rauf
u.s.w
Als Relais nutze ich eins von LCN. Hat jemand ne Idee wie ich da das Script ändern muß das eine Vernünftige Positionssteuerung herrauskommt??
MfG,
Martin