/** * @public * * Zustand Setzen * * @param boolean $power RGB Gerät On/Off * @param integer $color RGB Farben (Hex Codierung) * @param integer $level Dimmer Einstellung der RGB Beleuchtung (Wertebereich 0-100) */ public function SetState($power, $color, $level) { if (!$power) { @PJ_DimRGBW ($this->instanceId, 0, 2, 0, 2, 0, 2, 0, 2); } else { $red = floor($color/256/256); $green = floor(($color-$red*256*256)/256); $blue = floor(($color-$red*256*256-$green*256)); $red = floor($red*$level/100); $green = floor($green*$level/100); $blue = floor($blue*$level/100); @PJ_DimRGBW ($this->instanceId, $red, 2, $green, 2, $blue, 2, 0, 2); } }
public function SetState(boolean $NewState) { if (!$this->ReadPropertyInteger('ProJetDevice')) { die('Invalid or no ProJetDevice selected!'); } $ID = $this->GetIDForIdent('STATE'); $OldState = GetValue($ID); $dimState = $this->ReadPropertyInteger('DimState'); if ($OldState != $NewState) { if ($dimState) { $deviceId = $this->ReadPropertyInteger('ProJetDevice'); } if ($OldState) { $DeviceColor = $this->DeviceColor(); IPS_SetInfo($ID, serialize($DeviceColor)); if ($dimState) { PJ_DimRGBW($deviceId, 0, 2, 0, 2, 0, 2, 0, 0); self::_UpdateColor(array(0, 0, 0), false); } else { $DeviceColor = 0; } } else { if (!($DeviceColor = unserialize(IPS_GetInfo($ID)))) { $DeviceColor = 8355711; } if ($dimState) { $rgb = self::Int2Rgb($DeviceColor); PJ_DimRGBW($deviceId, $rgb[0], 2, $rgb[1], 2, $rgb[2], 2, 0, 0); self::_UpdateColor($rgb, false); } } if (!$dimState) { self::_UpdateColor($DeviceColor); } } }