RGBW868 Steuerung IPS2.5 mit Color Picker und Fade Timer

Das Projekt ist die Portierung meiner RGB Steuerung vom ChromoflexRCIII auf den RGBW868 von IPS.

changelog:
v1.0 initial release
v1.1 Mehrere Controller möglich (6 vorkonfiguriert)
v.2.0

  • AJAX Image Picker
  • Beliebig viele Controller möglich.

Vorbereitung:

Das Paket imagepickerRGBWv2.x.zip herunterladen und nach

Ihr_IPS_Ordner/webfront/user/imagepickerRGBW entpacken.

Also muss dann im Ordner User ein Ordner imagepickerRGBW sein.
Upgrade siehe weiter unten…

Installation:

  1. Dummy Modul erstellen.
  2. RGBW868 Instanz erstellen und auf Funktion prüfen. Hilfe in der Modulreferenz.
  3. Installations script erstellen.

<?
// Installationsscript für eine RGBW868 Steuerung v2.0 26.02.2012 Autor: NickBlue
// für IPS v2.5

/************ Konfiguration *************///

$RGBW868InstanzID = 39899 /*[Sripte und Doku\RGBW868Steuerung\RGBW868\RGBW-868 (Stripe)]*/ ;	// Hier muss die ID Ihrer RGBW868 Instanz eingetragen werden.


// Installationsscript kann nach Installation gelöscht werden.

/*********** Ab hier nichts mehr verändern *************///

//sucht die ID des übergeordneten Objekts sollte das Dummy Modul sein
$ParentID = IPS_GetObject($IPS_SELF);
$ParentID = $ParentID['ParentID'];

// Variablen Profile anlegen

$IDRGBW868profilname = @IPS_GetVariableIDByName("RGBW868profilname", $ParentID);
if ($IDRGBW868profilname === false)
	{
  		$Profiles = IPS_GetVariableProfileList();
		$ProfileVars = array_filter($Profiles, "RGBW868Prog"); // Filterfunktion
		$ProfileCounter = count($ProfileVars);  // Zählt die Treffer mit dem Filter
		while(IPS_VariableProfileExists(".RGBW868Programm" . $ProfileCounter)) {
		   $ProfileCounter++;
		}
		$RGBW868profilname = ".RGBW868Programm" . $ProfileCounter;
   }
else
	{
		$RGBW868profilname = GetValue($IDRGBW868profilname);
	}

function RGBW868Prog ($var)
	{
		if(preg_match("/.RGBW868Programm/",$var)) return true;
		return false;
	}

if (IPS_VariableProfileExists($RGBW868profilname)==False)
	{
		IPS_CreateVariableProfile($RGBW868profilname, 1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 0, "Aus","",0xFF0000);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 1, "Letzte Farbe","",0x00FF00);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 2, "Blinken","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 3, "Blinken Schnell","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 4, "Flash","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 5, "Flash Schnell","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 6, "Fade","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 99, "Manuell","",0x00FF00);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 100, "Auto","",0x00E5FF);
	}
else
	{
      IPS_DeleteVariableProfile($RGBW868profilname);
      IPS_CreateVariableProfile($RGBW868profilname, 1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 0, "Aus","",0xFF0000);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 1, "Letzte Farbe","",0x00FF00);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 2, "Blinken","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 3, "Blinken Schnell","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 4, "Flash","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 5, "Flash Schnell","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 6, "Fade","",-1);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 99, "Manuell","",0x00FF00);
		IPS_SetVariableProfileAssociation($RGBW868profilname, 100, "Auto","",0x00E5FF);
	}
if (IPS_VariableProfileExists(".FesteFarben")==False)
	{
		IPS_CreateVariableProfile(".FesteFarben", 1);
		IPS_SetVariableProfileAssociation(".FesteFarben", 0, "Rot ", "",0xFF0000);
		IPS_SetVariableProfileAssociation(".FesteFarben", 1, "Hellrot", "",0xFF1400);
		IPS_SetVariableProfileAssociation(".FesteFarben", 2, "Hellrot1", "",0xFF2800);
		IPS_SetVariableProfileAssociation(".FesteFarben", 3, "Rotorange", "",0xFF5000);
		IPS_SetVariableProfileAssociation(".FesteFarben", 4, "Orange", "",0xFF7800);
		IPS_SetVariableProfileAssociation(".FesteFarben", 5, "Gelb", "",0xFFFF00);
		IPS_SetVariableProfileAssociation(".FesteFarben", 6, "Grüngelb", "",0xC8FF00);
		IPS_SetVariableProfileAssociation(".FesteFarben", 7, "Hellgrün", "",0x64FF00);
		IPS_SetVariableProfileAssociation(".FesteFarben", 8, "Grün", "",0x00FF00);
		IPS_SetVariableProfileAssociation(".FesteFarben", 9, "Grünblau", "",0x00FF50);
		IPS_SetVariableProfileAssociation(".FesteFarben", 10, "Türkis", "",0x00FF90);
		IPS_SetVariableProfileAssociation(".FesteFarben", 11, "Hellblau", "",0x00FFFF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 12, "Royal", "",0x0064FF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 13, "Blau", "",0x0032FF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 14, "Dunkelblau", "",0x0000FF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 15, "Dunkellila", "",0x3E007A);
		IPS_SetVariableProfileAssociation(".FesteFarben", 16, "Lila", "",0x8907ED);
		IPS_SetVariableProfileAssociation(".FesteFarben", 17, "Magenta", "",0xFF00FF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 18, "Hellrose", "",0xC647ED);
		IPS_SetVariableProfileAssociation(".FesteFarben", 19, "Rosa", "",0xED0581);
		IPS_SetVariableProfileAssociation(".FesteFarben", 20, "Weiß", "",0xFFFFFF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 21, "Warmweiß", "",0xFFE478);
		IPS_SetVariableProfileAssociation(".FesteFarben", 22, "Eisweiß", "",0xABFFFC);
		IPS_SetVariableProfileAssociation(".FesteFarben", 23, "Weiß1", "",0xC9FFEB);
		IPS_SetVariableProfileAssociation(".FesteFarben", 24, "Weiß2", "",0xCAD9EB);
		IPS_SetVariableProfileAssociation(".FesteFarben", 99, "","transparent",-1);
	}
else
	{
      IPS_DeleteVariableProfile(".FesteFarben");
		IPS_CreateVariableProfile(".FesteFarben", 1);
		IPS_SetVariableProfileAssociation(".FesteFarben", 0, "Rot ", "",0xFF0000);
		IPS_SetVariableProfileAssociation(".FesteFarben", 1, "Hellrot", "",0xFF1400);
		IPS_SetVariableProfileAssociation(".FesteFarben", 2, "Hellrot1", "",0xFF2800);
		IPS_SetVariableProfileAssociation(".FesteFarben", 3, "Rotorange", "",0xFF5000);
		IPS_SetVariableProfileAssociation(".FesteFarben", 4, "Orange", "",0xFF7800);
		IPS_SetVariableProfileAssociation(".FesteFarben", 5, "Gelb", "",0xFFFF00);
		IPS_SetVariableProfileAssociation(".FesteFarben", 6, "Grüngelb", "",0xC8FF00);
		IPS_SetVariableProfileAssociation(".FesteFarben", 7, "Hellgrün", "",0x64FF00);
		IPS_SetVariableProfileAssociation(".FesteFarben", 8, "Grün", "",0x00FF00);
		IPS_SetVariableProfileAssociation(".FesteFarben", 9, "Grünblau", "",0x00FF50);
		IPS_SetVariableProfileAssociation(".FesteFarben", 10, "Türkis", "",0x00FF90);
		IPS_SetVariableProfileAssociation(".FesteFarben", 11, "Hellblau", "",0x00FFFF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 12, "Royal", "",0x0064FF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 13, "Blau", "",0x0032FF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 14, "Dunkelblau", "",0x0000FF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 15, "Dunkellila", "",0x3E007A);
		IPS_SetVariableProfileAssociation(".FesteFarben", 16, "Lila", "",0x8907ED);
		IPS_SetVariableProfileAssociation(".FesteFarben", 17, "Magenta", "",0xFF00FF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 18, "Hellrose", "",0xC647ED);
		IPS_SetVariableProfileAssociation(".FesteFarben", 19, "Rosa", "",0xED0581);
		IPS_SetVariableProfileAssociation(".FesteFarben", 20, "Weiß", "",0xFFFFFF);
		IPS_SetVariableProfileAssociation(".FesteFarben", 21, "Warmweiß", "",0xFFE478);
		IPS_SetVariableProfileAssociation(".FesteFarben", 22, "Eisweiß", "",0xABFFFC);
		IPS_SetVariableProfileAssociation(".FesteFarben", 23, "Weiß1", "",0xC9FFEB);
		IPS_SetVariableProfileAssociation(".FesteFarben", 24, "Weiß2", "",0xCAD9EB);
		IPS_SetVariableProfileAssociation(".FesteFarben", 99, "","transparent",-1);
	}

if (IPS_VariableProfileExists(".RGBW868FadeTimer")==False)
	{
		IPS_CreateVariableProfile(".RGBW868FadeTimer", 1);
		IPS_SetVariableProfileValues(".RGBW868FadeTimer", 0, 10, 1);
	}
else
	{
      IPS_DeleteVariableProfile(".RGBW868FadeTimer");
      IPS_CreateVariableProfile(".RGBW868FadeTimer", 1);
		IPS_SetVariableProfileValues(".RGBW868FadeTimer", 0, 10, 1);
	}
// Varianblen anlegen:

# Feste Farben
$VarID_FesteFarben = IPS_CreateVariable(1); // Variable erstellen
IPS_SetParent($VarID_FesteFarben, $ParentID); // Einordnen in Objektbaum
IPS_SetVariableCustomProfile($VarID_FesteFarben, ".FesteFarben"); // Profil setzen
IPS_SetName($VarID_FesteFarben, "Feste Farben"); // Name setzen
SetValueInteger($VarID_FesteFarben, 255);

#RGB Fader
$VarID_RGBFader = IPS_CreateVariable(1); // Variable erstellen
IPS_SetParent($VarID_RGBFader, $ParentID); // Einordnen in Objektbaum
IPS_SetVariableCustomProfile($VarID_RGBFader, "~HexColor"); // Profil setzen
IPS_SetName($VarID_RGBFader, "RGB Steuerung"); // Name setzen

# Weiss
$VarID_Weiss = IPS_CreateVariable(1); // Variable erstellen
IPS_SetParent($VarID_Weiss, $ParentID); // Einordnen in Objektbaum
IPS_SetVariableCustomProfile($VarID_Weiss, "~Intensity.255"); // Profil setzen
IPS_SetName($VarID_Weiss, "Weiss"); // Name setzen
SetValueInteger($VarID_Weiss, 255);

#Programm
$VarID_Programm = IPS_CreateVariable(1); // Variable erstellen
IPS_SetParent($VarID_Programm, $ParentID); // Einordnen in Objektbaum
IPS_SetVariableCustomProfile($VarID_Programm, $RGBW868profilname); // Profil setzen
IPS_SetName($VarID_Programm, "Programm"); // Name setzen

#FadeTimer
$VarID_FadeTimer = IPS_CreateVariable(1); // Variable erstellen
IPS_SetParent($VarID_FadeTimer, $ParentID); // Einordnen in Objektbaum
IPS_SetVariableCustomProfile($VarID_FadeTimer, ".RGBW868FadeTimer"); // Profil setzen
IPS_SetName($VarID_FadeTimer, "FadeTimer"); // Name setzen

# RGBAutomatikFarbWertRGB
$VarID_RGBWAutomatikFarbWert = IPS_CreateVariable(3); // Variable erstellen
IPS_SetParent($VarID_RGBWAutomatikFarbWert, $ParentID); // Einordnen in Objektbaum
IPS_SetName($VarID_RGBWAutomatikFarbWert, "RGBWAutomatikFarbWert"); // Name setzen
IPS_SetHidden($VarID_RGBWAutomatikFarbWert ,true); //Objekt verstecken

# RGBAutomatikFarbWertWeiss
$VarID_RGBWAutomatikFarbWertWeiss = IPS_CreateVariable(1); // Variable erstellen
IPS_SetParent($VarID_RGBWAutomatikFarbWertWeiss, $ParentID); // Einordnen in Objektbaum
IPS_SetName($VarID_RGBWAutomatikFarbWertWeiss, "RGBWAutomatikFarbWertWeiss"); // Name setzen
SetValueInteger($VarID_RGBWAutomatikFarbWertWeiss, 255);
IPS_SetHidden($VarID_RGBWAutomatikFarbWertWeiss ,true); //Objekt verstecken

# RGBManuellFarbWert
$VarID_RGBWManuellFarbWert = IPS_CreateVariable(3); // Variable erstellen
IPS_SetParent($VarID_RGBWManuellFarbWert, $ParentID); // Einordnen in Objektbaum
IPS_SetName($VarID_RGBWManuellFarbWert, "RGBWManuellFarbWert"); // Name setzen
IPS_SetHidden($VarID_RGBWManuellFarbWert ,true); //Objekt verstecken

# RGBManuellFarbWertWeiss
$VarID_RGBWManuellFarbWertWeiss = IPS_CreateVariable(1); // Variable erstellen
IPS_SetParent($VarID_RGBWManuellFarbWertWeiss, $ParentID); // Einordnen in Objektbaum
IPS_SetName($VarID_RGBWManuellFarbWertWeiss, "RGBWManuellFarbWertWeiss"); // Name setzen
SetValueInteger($VarID_RGBWManuellFarbWertWeiss, 255);
IPS_SetHidden($VarID_RGBWManuellFarbWertWeiss ,true); //Objekt verstecken

# RGBW868profilname
$VarID_RGBW868profilname = IPS_CreateVariable(3); // Variable erstellen
IPS_SetParent($VarID_RGBW868profilname, $ParentID); // Einordnen in Objektbaum
IPS_SetName($VarID_RGBW868profilname, "RGBW868profilname"); // Name setzen
IPS_SetHidden($VarID_RGBW868profilname ,true); //Objekt verstecken
SetvalueString($VarID_RGBW868profilname, $RGBW868profilname);

# Image Picker HTML Box
$VarID_ImagePicker = IPS_CreateVariable(3); // Variable erstellen
IPS_SetParent($VarID_ImagePicker, $ParentID); // Einordnen in Objektbaum
IPS_SetVariableCustomProfile($VarID_ImagePicker, "~HTMLBox"); // Profil setzen
IPS_SetName($VarID_ImagePicker, "Image Picker"); // Name setzen
SetvalueString($VarID_ImagePicker, '<iframe src="user/imagepickerRGBW/imageColorPicker.php?InstanzID='.$RGBW868InstanzID.'&RGBFaderID='.$VarID_RGBFader.'&ProgrammID='.$VarID_Programm.'&idFesteFarben='.$VarID_FesteFarben.'&FadeTimerID='.$VarID_FadeTimer.'&RGBWAutomatikFarbWertID='.$VarID_RGBWAutomatikFarbWert.'&RGBWManuellFarbWertID='.$VarID_RGBWManuellFarbWert.'&RGBWManuellFarbWertWeissID='.$VarID_RGBWManuellFarbWertWeiss.'&VariablenprofilID='.$VarID_RGBW868profilname.'" border="0" frameborder="0" style="top: 0pt; bottom: 0pt; left: 0pt; right: 0pt; width: 100%; height: 170px;"></iframe>');

// Anordnen


IPS_SetPosition($VarID_ImagePicker, 1);
IPS_SetPosition($VarID_FesteFarben, 2);
IPS_SetPosition($VarID_RGBFader, 3);
IPS_SetPosition($VarID_Weiss, 4);
IPS_SetPosition($VarID_Programm, 5);
IPS_SetPosition($VarID_FadeTimer, 6);
IPS_SetPosition($VarID_RGBWAutomatikFarbWert, 7);
IPS_SetPosition($VarID_RGBWAutomatikFarbWertWeiss, 8);
IPS_SetPosition($VarID_RGBWManuellFarbWert, 9);
IPS_SetPosition($VarID_RGBWManuellFarbWertWeiss, 10);
IPS_SetPosition($VarID_RGBW868profilname, 11);

// Funktion zur Script Erstellung

function CreateScriptByName($ScriptNAME, $ParentID, $ScriptTEXT)
{
   global $IPS_SELF;
    $ScriptID = @IPS_GetScriptIDByName($ScriptNAME, $ParentID);
    if ($ScriptID == 0){

       $ScriptID = IPS_CreateScript(0);
       IPS_SetName($ScriptID, $ScriptNAME);
       IPS_SetParent($ScriptID, $ParentID);
       IPS_SetInfo($ScriptID, "This script was created by: #$IPS_SELF#");
        $fh = fopen(IPS_GetKernelDir()."scripts\\".$ScriptID.".ips.php", 'w') or die("can't open file");
        fwrite($fh, $ScriptTEXT);
        fclose($fh);
        $ScriptPath = $ScriptID.".ips.php";     //Skriptdatei
        IPS_SetScriptFile($ScriptID, $ScriptPath);
        IPS_SetHidden($ScriptID, true);
       // echo "Die Skript-ID lautet: ". $ScriptID;
        return $ScriptID;
    }
}

// ############   Hauptscript anlegen: ######################## /////

$ScriptNAME = 'HauptscriptRGBW868Steuerung';

$ScriptIDHauptscriptRGBSteuerung = CreateScriptByName($ScriptNAME,$ParentID, // Funktionsaufruf und Scrip Erstellung
	'<?
// v2.0 RGBW868 Steuerung 26.02.2012 Autor: NickBlue für IPS 2.5


/*********** Ab hier nichts mehr verändern *************///

//  Konstanten definieren.

		define("RGBW868",  '.$RGBW868InstanzID.' /**/, true);    // ID der RGBW868 Instanz
      define("rgbfader", '.$VarID_RGBFader.' /**/, true);   // ID der Variable RGB Steuerung mit dem HEXCOLOR Profil
		define("weiss",     '.$VarID_Weiss.' /**/, true);    // ID der Variable weiss
      define("programm",   '.$VarID_Programm.' /**/, true);    // ID der Variable PROGRAMM
		define("FadeTimer",     '.$VarID_FadeTimer.' /**/, true);    // ID der Variable FadeTimer
    	define("FesteFarben",'.$VarID_FesteFarben.'  /**/, true); // ID der Variable Festen Farb Buttons
      define("RGBWAutomatikFarbWert",'.$VarID_RGBWAutomatikFarbWert.' /**/, true); // ID der Variable RGBWAutomatikFarbWert speichert den Auto Wert
      define("RGBWAutomatikFarbWertWeiss",'.$VarID_RGBWAutomatikFarbWertWeiss.' /**/, true); // ID der Variable RGBWAutomatikFarbWertWeiss speichert den Auto Wert
		define("RGBWManuellFarbWert",'.$VarID_RGBWManuellFarbWert.' /**/, true); // ID der Variable RGBWManuellFarbWert speichert den Manueel Wert
		define("RGBWManuellFarbWertWeiss",'.$VarID_RGBWManuellFarbWertWeiss.' /**/, true); // ID der Variable RGBWManuellFarbWertWeiss speichert den Manueel Wert
		define("RGBW868profilname",'.$VarID_RGBW868profilname.' /**/, true); // ID der Variable RGBWManuellFarbWertWeiss speichert den Manueel Wert

//*** Werte bei Betätigung aus dem Webfront einlesen und einer Variablen zuordnen ***//
if($IPS_SENDER == "WebFront")
	{
    	SetValue($IPS_VARIABLE, $IPS_VALUE);
	}

// Funktionsaufruf mit den Werten aus dem RGB Fader


$farb_rgb = hex2rgb(GetValueFormatted(rgbfader));
$farbmanuell_rgb = hex2rgb(GetValue(RGBWManuellFarbWert));

// Variablenwerte einlesen
$RGBW868   		= RGBW868;

$HexRGB 			= GetValueFormatted(rgbfader);
$weiss    		= GetValue(weiss);
$programm    	= GetValue(programm);
$FesteFarben 	= GetValue(FesteFarben);
$FadeTimer 		= GetValue(FadeTimer);
$RGBW868profilname = GetValue(RGBW868profilname);

$RGBWAutomatikFarbWert = GetValue(RGBWAutomatikFarbWert);
$RGBWAutomatikFarbWertWeiss = GetValue(RGBWAutomatikFarbWertWeiss);

$RGBWManuellFarbWert = GetValue(RGBWManuellFarbWert);
$RGBWManuellFarbWertWeiss = GetValue(RGBWManuellFarbWertWeiss);

$rot            = $farb_rgb[0];
$gruen        =  $farb_rgb[1];
$blau            = $farb_rgb[2];
$rotmanuell  = $farbmanuell_rgb[0];
$gruenmanuell = $farbmanuell_rgb[1];
$blaumanuell = $farbmanuell_rgb[2];

//Farbpalette (wie die im Herstellertool)
$cf_color_table=array
	(
    array(255, 0, 0, "FF0000", "Rot"),                /*/0: Rot */
    array(255, 20, 0,"FF1400", "Hellrot"),            /*/1: Hell3rot */
    array(255, 40, 0,"FF2800", "Hellrot1"),            /*/2: Hell2rot*/
    array(255, 80, 0,"FF5000", "Rotorange"),            /*/3: Hellrot*/
    array(255, 120, 0,"FF7800", "Orange"),            /*/4: Orange*/
    array(255, 255, 0,"FFFF00", "Gelb"),            /*/5: Gelb*/
    array(200, 255, 0,"C8FF00", "Grüngelb"),            /*/6: Gruengelb*/
    array(100, 255, 0,"64FF00", "Hellgrün"),            /*/7: Hellgruen*/
    array(0, 255, 0,"00FF00", "Grün"),            /*/8: Reingruen*/
    array(0, 255, 80,"00FF50", "Grünblau"),            /*/9: Leicht Indigo*/
    array(0, 255, 144,"00FF90", "Türkis"),            /*/10: Indigo*/
    array(0, 255, 255,"00FFFF", "Hellblau"),           /*/11: Hellblau*/
    array(0, 100, 255,"0064FF2", "Royal"),            /*/12: Hellblau*/
    array(0, 50, 255,"0032FF", "Blau"),            /*/13: Dunkelblau*/
    array(0, 0, 255,"0000FF", "Dunkelblau"),                /*/14: Royal*/
    array(50, 0, 255,"2300FF2", "Dunkellila"),        /*/15:*/
    array(100, 0, 255,"6400FF", "Lila"),            /*/16:*/
    array(255, 0, 255,"FF00FF", "Magenta"),            /*/17: Magenta*/
    array(255, 0, 100,"FF0064", "Hellrose"),            /*/18 */
    array(255, 0, 50,"FF0023", "Rosa"),            /*/19 */
    array(255, 255, 255,"FFFFFF", "Weiß"),            /*/ 20 *Weiss */
    array(255, 255, 80,"FFFF50", "Warmweiß"),            /*/ 21 Ungefaehr Weiss*/
    array(120, 255, 120,"78FF78", "Eisweiß"),            /*/ 22 Ungefaehr Weiss*/
    array(190, 255, 180,"BEFFB4", "Weiß1"),            /*/ 23 Ungefaehr Weiss*/
    array(160, 255, 255,"A0FFFF", "Weiß2")            /*/ 24 Ungefaehr Weiss */
	);

// Passende Funktion für Palette
function RGBW868_SetPalColor($objectId, $palColor, $weiss, $FadeTimer)
	{
  		global $cf_color_table;
      PJ_DimRGBW($objectId,$cf_color_table[$palColor][0],$FadeTimer,$cf_color_table[$palColor][1],$FadeTimer,$cf_color_table[$palColor][2],$FadeTimer,$weiss,$FadeTimer);
	}

// Funktion wandelt den RGB wert aus der RGB Fader Variable von Hex nach Dec und teilt sie in die Werte R G B
function hex2rgb ( $hex )
 	{
   	$rgb = array();
        	$rgb[0] = hexdec ( $hex[0] . $hex[1] );
        	$rgb[1] = hexdec ( $hex[2] . $hex[3] );
        	$rgb[2] = hexdec ( $hex[4] . $hex[5] );
   	return $rgb;
 	}

//**** Programmsteuerung ****////
if ($programm == 100)   // Wen Automatik an
	{
		switch ($IPS_VARIABLE)
			{  // *** RGB Colorfader ****///
				case (rgbfader):
         		SetValue (RGBWAutomatikFarbWert, GetValueFormatted(rgbfader)); // Farbe für Autmatik speichern
					$Profilcolor = GetValueFormatted(rgbfader);
					IPS_SetVariableProfileAssociation($RGBW868profilname, 100, "Auto","",hexdec($Profilcolor)); // Profil Color setzten
         	break;
         	// *** Weiss *** ///
            case (weiss):
               SetValue (RGBWAutomatikFarbWertWeiss, $weiss); // Farbe für Auto Weiss speichern
				break;
				// *** Feste Farben Buttens *** ///
				case (FesteFarben):
         		SetValue (RGBWAutomatikFarbWert, $cf_color_table[$FesteFarben][3]); // Farbe für Autmatik speichern
         		SetValue(rgbfader, hexdec ($cf_color_table[$FesteFarben][3]));
         		IPS_SetVariableProfileAssociation($RGBW868profilname, 100, "Auto","",hexdec($cf_color_table[$FesteFarben][3])); // Profil Color setzten
				break;
				// *** Programmwahl *** ///
				case  (programm):
      			SetValue(FesteFarben, 99);
     				SetValue(rgbfader, hexdec($RGBWAutomatikFarbWert));
     				SetValue(weiss, $RGBWAutomatikFarbWertWeiss);
            break;
			}
	}
else     // Wen Automatik aus
	{
      switch ($IPS_VARIABLE)
		{
// *** RGB Colorfader ****///
		case  (rgbfader):
				$farb_rgb = hex2rgb(GetValueFormatted(rgbfader));
				PJ_DimRGBW($RGBW868,$rot,$FadeTimer,$gruen,$FadeTimer,$blau,$FadeTimer,$RGBWManuellFarbWertWeiss,$FadeTimer);
         	SetValue(FesteFarben, 99); // FesteFarben auf Manuell umschalten
         	SetValue(weiss, $RGBWManuellFarbWertWeiss);
         	SetValue (RGBWManuellFarbWert, $HexRGB); // Farbe für Manuell speichern
         	$Profilcolor = GetValueFormatted(rgbfader);
				IPS_SetVariableProfileAssociation($RGBW868profilname, 99, "Manuell","",hexdec($Profilcolor)); // Profilfarbe setzen
				IPS_SetVariableProfileAssociation($RGBW868profilname, 1, "Letzte Farbe","",hexdec($Profilcolor)); // Profilfarbe setzen
				if ($programm == 0)
					{
						SetValue(programm, 99);
					}
	 	break;
      case  (weiss):

            SetValue (RGBWManuellFarbWertWeiss, $weiss); // Farbe für Manuell Weiss speichern
				$farb_rgb = hex2rgb(RGBWManuellFarbWert);
				PJ_DimRGBW($RGBW868,$rot,$FadeTimer,$gruen,$FadeTimer,$blau,$FadeTimer,$weiss,$FadeTimer);
            SetValue(rgbfader, hexdec($RGBWManuellFarbWert));

				SetValue(FesteFarben, 99); // FesteFarben auf Manuell umschalten
				if ($programm == 0)
					{
						SetValue(programm, 99);
					}
		break;
// *** Programmwahl *** ///
		case  (programm):
			if ($IPS_VALUE < 50 and $IPS_VALUE != 0) // Hersteller Programm
				{
      			PJ_RunProgram($RGBW868, $programm);
      			SetValue(FesteFarben, 99);
      			SetValue(rgbfader, hexdec($RGBWManuellFarbWert));
      			SetValue(weiss, $RGBWManuellFarbWertWeiss);
				}
			else
			   {
               PJ_RunProgram($RGBW868, 0);
      			SetValue(FesteFarben, 99);
      			SetValue(rgbfader, 0);
      			SetValue(weiss, 0);
				}
			if ($IPS_VALUE == 99) // Manuell ausgewählt
			   {
               SetValue(rgbfader, hexdec($RGBWManuellFarbWert));
               $farbmanuell_rgb = hex2rgb($RGBWManuellFarbWert);
               SetValue(weiss, $RGBWManuellFarbWertWeiss);
               PJ_DimRGBW($RGBW868,$rotmanuell,$FadeTimer,$gruenmanuell,$FadeTimer,$blaumanuell,$FadeTimer,$RGBWManuellFarbWertWeiss,$FadeTimer);
				}
	   break;
// *** Feste Farben Buttens *** ///
		case  (FesteFarben):
		   if  ($FesteFarben < 99)
				{
					$funktionsreturn = RGBW868_SetPalColor($RGBW868, $FesteFarben,$RGBWManuellFarbWertWeiss,$FadeTimer);// Funktionsaufruf anhand des gedrückten Buttens FesteFarben im WebFront.
         		SetValue(rgbfader, hexdec ($cf_color_table[$FesteFarben][3]));
               SetValue(weiss, $RGBWManuellFarbWertWeiss);
					$Profilcolor = $cf_color_table[$FesteFarben][3];
					IPS_SetVariableProfileAssociation($RGBW868profilname, 99, "Manuell","",hexdec($Profilcolor)); // Profilfarbe setzen
					IPS_SetVariableProfileAssociation($RGBW868profilname, 1, "Letzte Farbe","",hexdec($Profilcolor)); // Profilfarbe setzen
					SetValue (RGBWManuellFarbWert, $cf_color_table[$FesteFarben][3]); // Farbe für Manuell speichern
					if ($programm == 0)
					{
						SetValue(programm, 99);
					}
         	}
	   break;
		}
	}
?>'
);

// Script den Variablen zuweisen

IPS_SetVariableCustomAction($VarID_RGBFader, $ScriptIDHauptscriptRGBSteuerung); // Script zuweisen
IPS_SetVariableCustomAction($VarID_Weiss, $ScriptIDHauptscriptRGBSteuerung); // Script zuweisen
IPS_SetVariableCustomAction($VarID_Programm, $ScriptIDHauptscriptRGBSteuerung); // Script zuweisen
IPS_SetVariableCustomAction($VarID_FadeTimer, $ScriptIDHauptscriptRGBSteuerung); // Script zuweisen
IPS_SetVariableCustomAction($VarID_FesteFarben, $ScriptIDHauptscriptRGBSteuerung); // Script zuweisen


echo " <p>Installation Abgeschlossen.</p>
<p>
<br /> Es sollten jetzt alle Scripte und Variablen angelegt sein.
<br /> 
</p>
<p><br />Dieses Script kann gelöscht werden</p>";

?>

  1. Installationsscript konfigurieren und ausführen.
  2. Installation testen und das Installationsscript löschen.

Gruß
NickBlue

RGB.png

ColorPicker.png

imagepickerRGBWv2.0.zip (670 KB)

Hi NickBlue,

ganz großes Lob für das Script.
Eingerichtet gestartet und es funkt.

Allerdings habe ich 3 von den RGB Modulen im Einsatz.
Kannste mir mal einen kurzen Tipp geben (bevor ich das Script zerkege) wie ich die einbinden kann bzw. an welcher Stelle ich die colorpicker.php und colorpicker1.php so einbinden, verändern oder umbenennen muss das ich diese auch auf die anderen Module nutzen kann.

Im voraus besten Dank.

Danke wibo,

habe mir gedacht das die Frage kommt :D.
Werde mal eine vorläufige Notlösung bauen.

Gruß nick

habe das Script um die option mehrcontroller erweitert.

Version 1.1

lösche bitte die erste installation die du hast und für das neue installationsscript jeweils mit einer anderen Controllernummer in einem separaten Dummy Modul aus. 6 sind Möglich.

Gruß Nick

Danke prima klappt,

schicke dir per fax ne Falsche Champus.

Und nochmals großes Lob für die Arbeit.

Hier ein Vorgeschmak der Version 1.2

Bild ist aber noch von der Chromo Steuerung.

Das ding ist HTML 5 Canvas und CSS3 gebaut.

Ihr könnt dan jedes X belibige Bild nehmen.

Guß Nick

Habs heute mittag installiert.
Läuft ohne Probleme.

Danke für deine Arbeit

Nick,

meinst Du das es vielleicht ohne den Senden-Button auskommt.

Das Ding nervt mich echt gesagt. Es muss doch ausrreichen wenn man auf eine Farbe klickt.

Ich meine damit das man jedes Bild dann als ColorPicker nutzen kann.

Das Ding nervt mich echt gesagt. Es muss doch ausrreichen wenn man auf eine Farbe klickt.

Die Picker befüllen ein Formularfelt welches nach dem absenden den Wert ausliest und damit die Werte für den Schaltbefehl setzt.

in jscript gibt es on click varianten für sowas.
Jedoch kann ich so gut wie garnicht jscript sorry.

muss für die Picker zu Programieren schon sehr viel lesen.
Wenn einer der JScript Programierer dort hilft wer net.
Komme auch nicht so gut mit dem Dojo klar.

Mich persöhnlich stört es nicht im gegenteil. Dann kann mam wenigstens noch koriegieren bevor man das ding absendet.

Eine Echtzeitfunktion aktevier/deaktivierbar ist natürlich eine gute Idee.

Gruß nick

Siehe drüben im „Chromoflex“ Thread. Mit JS und onclick ja wäre vielleicht auch gegangen. Aber dann läd der ganze Quatsch immer wieder neu. So jetzt wird per Ajax (JS Httprequest) der Status an IPS gemeldet und gut ist.

Gruß,
Jan

Hallo Nick,
sowas such ich schon lange !

Das Script hier sieht super aus - jedoch bräuchte ich es etwas modifiziert - habe aber keine Idee wo anfangen und wo aufhören :slight_smile:

Da ich DALi-Steuergeräte und keine Chromoflex drin habe:

Der ColorPicker soll nur die 3 Farbwerte in Variablen ablegen.

Das ganze blinki-blink und Programm-Modus-Zeugs der Chromoflex´s kann raus…

Würdest Du mir bitte unter die Arme greifen ? Herzlichen Dank !

Schau dir doch mal an was ich in dem Chromoflexthread gepostet habe (Link siehe mein vorhigen post). Das dürfte genau das machen was du willst.

Gruß,
Jan

Hallo Jan,

Danke für den Hinweis - aber mit dienen „essentials“ komm ich gar nicht klar.
Ich raff das nicht obs A) nur deine beiden scripte sind B) welche variabele mit welchem Namen anzulegen ist C) warum die scripte nur extra im Webfront/user und warum nicht über IPS anlegen D) welche controller ID, wenn ich doch keinen Chromo hab.

Ich bräuchte die RGB-Werte aus dem Picker in einzelnen Variablene für R + G + B oder in nem Array das ich dann in mein Dali Script übergebe…

Tja, es fehlt weiter :slight_smile:

Wir können das schnell im Temvierer zusammen machen.
Habe im Moment leider wenig Zeit um an den Steuerungen im Forum weiter zu arbeiten. Da wir momentan die Steuerung in Ajax gebaut haben und eine Multitouch Oberfkäche mit Dojo schreiben.

Schreib mir doch per PN wann du das machen möchtest.
Ist nicht viel Arbeit.

Iframe erstellten 2. Dateien >> Fertig geht schnell.

Gruß nick

Bei meinen Essentials legst du die beiden Scripte in den Webfront Ordner ab und legst zwei Variablen an. Eine String mit dem „iframe“ inhalt und eine int, wenn Du magst mit Hexcolor als Profil. Und dessen ID packete bei dem Iframe Aufruf mit rein.

Die Scripte sind im Webfront ordner und nicht in IPS, weil die quasi „extern“ aufgerufen werden (durch das html).

Achja dann noch ein Script anlegen was onchange von der Int Variable triggert. Hier die Var auslesen und an dein Script übergeben. Zack das wars.

Aber sonst auch gerne Teamviewer ^^. Erstmal ICQ: 432035520

Oh btw. ich habe auch noch was gebstelt was „szenarien“ abspeichert. ist jetzt nicht unebdingt reif fürs Forum aber wenn es jmd interessiert …

Gruß,
Jan

ja mich :wink: haben Wollen…

Meine Scripte speichern alle Integer Variablen-Werte die sichtbar sind unter einer ID.

Das „Speicher Script“

<?
IPS_SetHidden($_IPS['SELF'], true);
$profile = GetValue(IPS_GetParent(IPS_GetParent($_IPS['SELF'])));

$ParentID = IPS_GetObject($IPS_SELF);
$ParentID = $ParentID['ParentID'];

$ParentID = IPS_GetObject($ParentID);
$ParentID = $ParentID['ParentID'];

$GrandParentID = IPS_GetObject($ParentID);
$GrandParentID = $GrandParentID['ParentID'];


$t = goTree ($GrandParentID);
$scenarioProfiles = json_decode(GetValue(39003 /*[Lights\Scenario\SaveScenario\SaveScenario\ScenarioSave]*/),true);

$scenarioProfiles[$profile] = $t;


$t2 = json_encode($scenarioProfiles);
SetValue(39003 /*[Lights\Scenario\SaveScenario\SaveScenario\ScenarioSave]*/,$t2);


function goTree ($id) {
	global $ParentID;
	$erg = Array();
	$childs = IPS_GetChildrenIDs($id);
	foreach ($childs as $child) {
		$o = IPS_GetObject($child);
		//print_r ($o);
		if ($o["ObjectIsHidden"] != 1 && $child <> $ParentID) { // $o["ObjectType"] == 0
			$tmp = goTree ($child);
			$erg = $erg + $tmp;
		}
		if ($o["ObjectType"] == 2) { // Typ Variable
			$v = IPS_GetVariable($child);
			if ($v["VariableValue"]["ValueType"] == 1) { // Integer
				$erg[$child] = GetValue ($child);
			}
		}
	}
	return ($erg);
}

?>

Statt dem Teil hier würde sich wohl anbieten GrandParentID = ID des Baumes der gespeichert werden soll. Aber wenn man es so aufbaut wie ich kann man das natürlich auch lassen.

$ParentID = IPS_GetObject($IPS_SELF);
$ParentID = $ParentID['ParentID'];

$ParentID = IPS_GetObject($ParentID);
$ParentID = $ParentID['ParentID'];

$GrandParentID = IPS_GetObject($ParentID);
$GrandParentID = $GrandParentID['ParentID'];

Das einlese Script:

<?php
	IPS_SetHidden(36183 /*[Lights\Scenario\SaveScenario\SaveScenario]*/, true);
	
$profile = GetValue(IPS_GetParent($_IPS['SELF']));

$scenarioProfiles = json_decode(GetValue(39003 /*[Lights\Scenario\SaveScenario\SaveScenario\ScenarioSave]*/),true);
$s = $scenarioProfiles[$profile];
//print_r ($scenarioProfiles);

foreach ($s as $key => $t4) {
	//echo "$key -> $t4 
";
	@SetValue ($key, $t4);
}
IPS_RunScript (35127 /*[Lights\Hidden\Send to Arduino]*/);

goTree (IPS_GetParent(IPS_GetParent($_IPS['SELF'])));


function goTree ($id) {
	$erg = Array();
	$childs = IPS_GetChildrenIDs($id);
	foreach ($childs as $child) {
		$o = IPS_GetObject($child);
		//print_r ($o);
		if ($o["ObjectIsHidden"] != 1) { // $o["ObjectType"] == 0
			$tmp = goTree ($child);
			$erg = $erg + $tmp;
		}
		if ($o["ObjectType"] == 2 && $o["ObjectName"] == "Color Picker") { // Typ Variable
				SetValue($child, GetValue ($child));
		}
	}
	return ($erg);
}
?>

Und so ist die Struktur bei mir:

Go ist jeweils nur das Actionscript das nur aus:
SetValue($IPS_VARIABLE, $IPS_VALUE); // Wert auch in Var Setzen …
besteht.
Und das erste SaveSenario besteht nur aus:
IPS_SetHidden(36183 /[Lights\Scenario\SaveScenario\SaveScenario]/, false);

Das bedeutet beim speichern muss man zwei mal klicken. Zur Sicherheit, das man nicht ausversehen Szenarien überschreibt.

Hoffe Du kannst was damit anfangen. Sonst Frag oder ICQ. Vielleicht bastelst Du dafür ja auch ein Installer, dann können noch andere was damit anfangen :wink:

Gruß,
Jan

So Fans der bunten Lichter.

Die Version 2.0 ist fertig.

Hat etwas gedauert da wir es in AJAX Programiert haben.

Gruß Nick

Hallo Nick,

sind gegenüber dem was ich gebastelt hatte nennenwerte Unterschiede (mal abgesehen von den coolen Pickflächen)? Damit ich weiß ob es sich lohnt noch mal anzusehen / abzuändern :wink:

Gruß,
Jan

Multicontroller und das Element ist jetzt in Canvas und Ajax gebaut.