So, nun ist das Skript hübscher - ich habe es mit dem Farbrad von IPS verheiratet.
Folgende Arbeitsschritte:
-
Dummy-Instanz anlegen. Die erzeugten Objekte in Punkt 2-6 in dieser Instanz ablegen.
-
Integer-Variable mit Namen „HexColor“ und Profil HexColor anlegen.
-
Integer-Variable mit Namen „Hue (Farbton)“ ohne Profil anlegen.
-
Integer-Variable mit Namen „Luminance (Helligkeit)“ und Profil ~Intensity.255 anlegen.
-
Integer-Variable mit Namen "Saturation (Sättigung) ohne Profil anlegen.
-
Skript mit folgendem Inhalt erstellen:
<?
/*
http://www.limitlessled.com/dev/
LimitlessLED v3.0 OpenSource API
Wifi Bridge Router Web Config: http://10.10.100.254/home.html Username: admin Password: admin
All UDP Commands are 3 Bytes. First byte is from the list below, plus a fixed 2 byte suffix of 0x00 (decimal: 0) and 0x55 (decimal: 85)
i.e. to turn all RGBW COLOR LimitlessLED Smart lights to ON then send the TCP/IP UDP packet of: 0x42 0x00 0x55
Hexidecimal (byte) Decimal (integer)
RGBW COLOR LED ALL OFF 0x41 65
RGBW COLOR LED ALL ON 0x42 66
DISCO SPEED SLOWER 0x43 67
DISCO SPEED FASTER 0x44 68
GROUP 1 ALL ON 0x45 69 (SYNC/PAIR RGB+W Bulb within 2 seconds of Wall Switch Power being turned ON)
GROUP 1 ALL OFF 0x46 70
GROUP 2 ALL ON 0x47 71 (SYNC/PAIR RGB+W Bulb within 2 seconds of Wall Switch Power being turned ON)
GROUP 2 ALL OFF 0x48 72
GROUP 3 ALL ON 0x49 73 (SYNC/PAIR RGB+W Bulb within 2 seconds of Wall Switch Power being turned ON)
GROUP 3 ALL OFF 0x4A 74
GROUP 4 ALL ON 0x4B 75 (SYNC/PAIR RGB+W Bulb within 2 seconds of Wall Switch Power being turned ON)
GROUP 4 ALL OFF 0x4C 76
DISCO MODE 0x4D 77
SET COLOR TO WHITE (GROUP ALL) 0x42 100ms followed by: 0xC2
SET COLOR TO WHITE (GROUP 1) 0x45 100ms followed by: 0xC5
SET COLOR TO WHITE (GROUP 2) 0x47 100ms followed by: 0xC7
SET COLOR TO WHITE (GROUP 3) 0x49 100ms followed by: 0xC9
SET COLOR TO WHITE (GROUP 4) 0x4B 100ms followed by: 0xCB
LIMITLESSLED RGBW DIRECTLY SETTING THE BRIGHTNESS is by a 3BYTE COMMAND: (First send the Group ON for the group you want to set the brightness for. You send the group ON command 100ms before sending the 4E 1B 55)
Byte1: 0x4E (decimal: 78)
Byte2: 0×02 to 0x1B (decimal range: 2 to 27) full brightness 0x1B (decimal 27)
Byte3: Always 0×55 (decimal: 85)
LIMITLESSLED RGBW COLOR SETTING is by a 3BYTE COMMAND: (First send the Group ON for the group you want to set the colour for. You send the group ON command 100ms before sending the 40)
Byte1: 0×40 (decimal: 64)
Byte2: 0×00 to 0xFF (255 colors) See Color Matrix Chart for the different values below.
Byte3: Always 0×55 (decimal: 85)
Byte2: Color Matrix Chart: (thanks Stephan Schaade, http://knx-user-forum.de http://mknx.github.io/smarthome/)
0x00 Violet
0x10 Royal_Blue
0x20 Baby_Blue
0x30 Aqua
0x40 Mint
0x50 Seafoam_Green
0x60 Green
0x70 Lime_Green
0x80 Yellow
0x90 Yellow_Orange
0xA0 Orange
0xB0 Red
0xC0 Pink
0xD0 Fusia
0xE0 Lilac
0xF0 Lavendar
*/
// Trigger-Variable setzen
SetValue ($_IPS['VARIABLE'], $_IPS['VALUE']);
// Variablen-IDs, RGB-Gruppe und Controller-Instanz definieren
$id_rgb = xxxxx /*[RGBW-WLAN1 Erdgeschoss]*/; // [RGBW-WLAN1 Erdgeschoss
$Gruppe = 1; // Gruppennummer RGB-Leuchtmittel
$HexColorID = IPS_GetObjectIDByName("HexColor", IPS_GetParent($_IPS['SELF']));
$LuminanceID = IPS_GetObjectIDByName("Luminance (Helligkeit)", IPS_GetParent($_IPS['SELF']));
// =====================================================================================
// AB HIER NICHTS MEHR ÄNDERN !!
// =====================================================================================
// Gruppen Steuercodes festlegen
switch ($Gruppe) {
case 1: // Gruppe 1
$GruppeAN = "\x45";
$GruppeAUS = "\x46";
$GruppeWeiss = "\xc5";
break;
case 2: // Gruppe 2
$GruppeAN = "\x47";
$GruppeAUS = "\x48";
$GruppeWeiss = "\xc7";
break;
case 3: // Gruppe 3
$GruppeAN = "\x49";
$GruppeAUS = "\xa";
$GruppeWeiss = "\xc9";
break;
case 4: // Gruppe 4
$GruppeAN = "\x4b";
$GruppeAUS = "\x4c";
$GruppeWeiss = "\xcb";
break;
}
// Werte aus HEXCOLOR übernehmen und aufteilen
$ValueDEC = $_IPS['VALUE'];
$ValueHEX = dechex($_IPS['VALUE']);
$ValueHEX = substr("000000", 0, 6 - strlen($ValueHEX)).$ValueHEX;
$rotHex = substr($ValueHEX, 4, 2);
$rotDec = round(hexdec($rotHex));
$gruenHex = substr($ValueHEX, 2, 2);
$gruenDec = round(hexdec($gruenHex));
$blauHex = substr($ValueHEX, 0, 2);
$blauDec = round(hexdec($blauHex));
// Array für Funktion rgb2hsl befüllen
$rgb[0] = $rotDec;
$rgb[1] = $gruenDec;
$rgb[2] = $blauDec;
// Umrechnung anstossen und in Array und Ergebnisvariablen ablegen
$ValueHSL = rgb2hsl ($rgb);
$Hue = $ValueHSL['Hue'];
$Saturation = $ValueHSL['Saturation'];
$Luminance = $ValueHSL['Luminance'];
// Werte an RGB-WLAN-Controller ausgeben
// UDP RGB Socket öffnen
CSCK_SetOpen($id_rgb, true);
IPS_ApplyChanges($id_rgb);
// RGB Einstellungen übertragen
if ($_IPS['VARIABLE'] == $HexColorID and $Luminance >= 2) {
// Farbwerte senden
USCK_SendText($id_rgb, $GruppeAN."\x00\x55"); // Sende Gruppe xyz AN
ips_sleep(110);
$Output = "\x40".chr($Hue)."\x55";
USCK_SendText($id_rgb, $Output); // Sende Farbwert an Gruppe xyz
ips_sleep(110);
// Helligkeit senden
// Anpassung an den zulässigen Wertebereich 2-27 Dezimal
$Luminance2 = round(($Luminance / 9.44), 0);
if ($Luminance2 < 2) $Luminance2 = 2;
if ($Luminance2 > 27) $Luminance2 = 27;
USCK_SendText($id_rgb, $GruppeAN."\x00\x55"); // Sende Gruppe xyz AN
ips_sleep(110);
$Output = "\x4e".chr($Luminance2)."\x55";
USCK_SendText($id_rgb, $Output); // Sende Helligkeit an Gruppe xyz
// Wert in Variable Helligkeit schreiben
SetValue($LuminanceID, $Luminance);
return;
}
// "Weisse" Einstellungen übertragen
if ($_IPS['VARIABLE'] == $LuminanceID and $Luminance >= 2) {
// Gruppe auf Modus "Weiss" schalten
USCK_SendText($id_rgb, $GruppeAN."\x00\x55"); // Sende Gruppe xyz AN
ips_sleep(110);
USCK_SendText($id_rgb, $GruppeWeiss."\x00\x55"); // Sende "Weiss" an Gruppe xyz
ips_sleep(110);
// Helligkeit senden
// Anpassung an den zulässigen Wertebereich 2-27 Dezimal
$Luminance2 = round(($Luminance / 9.44), 0);
if ($Luminance2 < 2) $Luminance2 = 2;
if ($Luminance2 > 27) $Luminance2 = 27;
$Output = "\x4e".chr($Luminance2)."\x55";
USCK_SendText($id_rgb, $GruppeAN."\x00\x55"); // Sende Gruppe xyz AN
ips_sleep(110);
USCK_SendText($id_rgb, $Output); // Sende Helligkeit an Gruppe xyz
// Wert in Variable HexColor schreiben
SetValue($HexColorID, "000000");
return;
}
// Gruppe ausschalten
if ($Luminance < 2) {
USCK_SendText($id_rgb, $GruppeAUS."\x00\x55"); // Sende Gruppe xyz AUS
// Wert in Variable Helligkeit schreiben
SetValue($LuminanceID, $Luminance);
// Wert in Variable HexColor schreiben
SetValue($HexColorID, "000000");
}
//UDP RGP Socket wieder schließen
//CSCK_SetOpen($id_rgb, false);
//IPS_ApplyChanges($id_rgb);
// Funktion übernommen von www.php.net und an eigene Bedürfnisse angepasst
// Convert RGB colors array into HSL array
// @param array $ RGB colors set, each color component with range 0 to 255
// @return array HSL set, each color component with range 0 to 1
function rgb2hsl($rgb){
$clrR = ($rgb[0]);
$clrG = ($rgb[1]);
$clrB = ($rgb[2]);
$clrMin = min($clrR, $clrG, $clrB);
$clrMax = max($clrR, $clrG, $clrB);
$deltaMax = $clrMax - $clrMin;
$L = ($clrMax + $clrMin) / 510;
if (0 == $deltaMax){
$H = 0;
$S = 0;
}
else{
if (0.5 > $L){
$S = $deltaMax / ($clrMax + $clrMin);
}
else{
$S = $deltaMax / (510 - $clrMax - $clrMin);
}
if ($clrMax == $clrR) {
$H = ($clrG - $clrB) / (6.0 * $deltaMax);
}
else if ($clrMax == $clrG) {
$H = 1/3 + ($clrB - $clrR) / (6.0 * $deltaMax);
}
else {
$H = 2 / 3 + ($clrR - $clrG) / (6.0 * $deltaMax);
}
if (0 > $H) $H += 1;
if (1 < $H) $H -= 1;
}
$H = round(($H * 255), 0);
$S = round(($S * 255), 0);
$L = round(($L * 255), 0);
$HSLColor = array( 'Hue' => $H, 'Saturation' => $S, 'Luminance' => $L );
return $HSLColor;
}
// Funktion Ende
?>
-
Dieses Skript den Variablen von Punkt 2 und 4 als Actionskript zuordnen.
-
UDP-Socket anlegen mit Sende-/Empfangsport 8899. Sende-Host ist die IP des Wifi-Controller, Empfangs-Host ist egal - ich habe da die IP des IPS-Rechners eingetragen.
-
Im Skript die ID des UDP-Sockets eintragen.
-
Im Webfront zwei Links auf die Variablen aus Punkt 2 und 4 anlegen. Beschriftung nach Geschmack.
-
Hoffen, dass ich nichts vergessen habe und es Licht werden lassen.
Die Bedienung des Farbrades ist glaube ich klar, der zweite Link steuert die Farbe Weiss und deren Helligkeit.
Das Ganze funktioniert bei mir mit Firmware 3.x des Controllers - die neue 4.x habe ich nicht zur Verfügung.