Ok, hier das Skript:
<?
if ($IPS_SENDER == "WebFront") {
$bit0 = IPS_GetVariableIDByName("Bit 0", $IPS_VARIABLE);
$bit1 = IPS_GetVariableIDByName("Bit 1", $IPS_VARIABLE);
$bit2 = IPS_GetVariableIDByName("Bit 2", $IPS_VARIABLE);
$bit3 = IPS_GetVariableIDByName("Bit 3", $IPS_VARIABLE);
$bit4 = IPS_GetVariableIDByName("Bit 4", $IPS_VARIABLE);
$bit5 = IPS_GetVariableIDByName("Bit 5", $IPS_VARIABLE);
$id_profilenr = IPS_GetVariableIDByName("ProfileNr", $IPS_VARIABLE);
$id_instance = IPS_GetParent($IPS_VARIABLE);
$id_working = IPS_GetStatusVariableID($id_instance, "WORKING");
$id_level = IPS_GetStatusVariableID($id_instance, "LEVEL");
$id_inhibit = IPS_GetStatusVariableID($id_instance, "INHIBIT");
$profilenr = GetValue($id_profilenr);
$profile = "BitMask_Rolladen_".str_pad($profilenr, 2 ,'0', STR_PAD_LEFT);
switch ($IPS_VALUE) {
case 0:
/* Rolladen schließen */
if (GetValue($id_working)) {
HM_WriteValueBoolean($id_instance, "STOP", true);
} else {
HM_WriteValueFloat($id_instance, "LEVEL", 0);
}
SetValue($IPS_VARIABLE, 0);
/* Restliche Bits visualisieren */
if (!GetValue($bit2)) {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
}
if (!GetValue($bit3)) {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
}
if (!GetValue($bit4)) {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
}
if (!GetValue($bit5)) {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
}
break;
case 1:
/* Rolladen öffnen */
if (GetValue($id_working)) {
HM_WriteValueBoolean($id_instance, "STOP", true);
} else {
HM_WriteValueFloat($id_instance, "LEVEL", 1);
}
SetValue($IPS_VARIABLE, 1);
/* Restliche Bits visualisieren */
if (!GetValue($bit2)) {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
}
if (!GetValue($bit3)) {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
}
if (!GetValue($bit4)) {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
}
if (!GetValue($bit5)) {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
}
break;
case 2:
if (!GetValue($bit2)) {
SetValue($bit2, true);
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
} else {
SetValue($bit2, false);
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
}
if (!GetValue($bit3)) {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
}
if (!GetValue($bit4)) {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
}
if (!GetValue($bit5)) {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
}
break;
case 3:
if (!GetValue($bit2)) {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
}
if (!GetValue($bit3)) {
SetValue($bit3, true);
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
} else {
SetValue($bit3, false);
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
}
if (!GetValue($bit4)) {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
}
if (!GetValue($bit5)) {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x00ff);
}
break;
case 4:
if (!GetValue($bit2)) {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
}
if (!GetValue($bit3)) {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
}
if (!GetValue($bit4)) {
SetValue($bit4, true);
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
} else {
SetValue($bit4, false);
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
}
if (!GetValue($bit5)) {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
}
break;
case 5:
if (!GetValue($bit2)) {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
}
if (!GetValue($bit3)) {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
}
if (!GetValue($bit4)) {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
} else {
IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
}
if (!GetValue($bit5)) {
HM_WriteValueBoolean($id_instance, "INHIBIT", true);
SetValue($bit5, true);
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
} else {
HM_WriteValueBoolean($id_instance, "INHIBIT", false);
SetValue($bit5, false);
IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
}
break;
}
}
?>
Damit bin ich jetzt erstmal zufrieden. Das die Auswahlmöglichkeiten ausgegraut sind, ist ok, da ich über „Geschlossen“ und „Geöffnet“ noch den aktuellen Zustand des Rolladens anzeige.