function Entertainment_Before_SendData($Parameters) {
		if ($Parameters[0]==c_Comm_WinLIRC and $Parameters[1]=='yamahareceiver') {
			$Button      = $Parameters[2];

			// Special Handling for Muting of YamahaReceiver: Use InputSelector Phone for Muting,
			// Switch back to current Input when Muting Off
			// ==================================================================================
			if ($Button == "muteon") {
				IPSLogger_Dbg(__file__, "Set Muting 'On' for Yamaha Receiver (Switch to Phone Input)");
            WinLIRC_SendData(array(c_Comm_WinLIRC, 'yamahareceiver', 'phone'));
				return false; // Abort current Processing

			} else if ($Button=='muteoff') {
				$RoomId = get_RoomId(c_Room_LivingRoom);
				$SourceIdx = get_SourceIdxByRoomId($RoomId);
		   	Entertainment_SendDataBySourceIdx($RoomId, $SourceIdx, c_MessageType_Action);
				return false; // Abort current Processing

		   // Special Handling for Yamaha Tuner, YamahaReceiver supports only Previous/Next Station for Tuner
		   // --> Simulate Buttons for Station "1" - "8" by Previous and Next.
	   	// ===============================================================================================
			} else if ($Button == "0" or $Button == "1" or $Button == "2" or $Button == "3" or $Button == "4" or
			           $Button == "5" or $Button == "6" or $Button == "7") {
				$ControlId   = get_ControlIdByDeviceName(c_Device_YamahaTuner, c_Control_Program);
				$StationNew  = GetValue($ControlId);
				$StationObj  = IPS_GetObject($ControlId);
				$StationCurr = $StationObj["ObjectInfo"];
				IPSLogger_Trc(__file__, "Switch YamahaTuner from StationCurrent=".$StationCurr." to  StationNew=".$StationNew);

				if ($StationNew-$StationCurr <= 4 and $StationNew-$StationCurr >= 0) {
				   $IRButton = 'presetnext';
					$Count = $StationNew-$StationCurr;
				} else if (($StationCurr-$StationNew) < 0) {
				   $IRButton = 'presetlast';
					$Count = 8-($StationNew-$StationCurr);
				} else if (($StationCurr-$StationNew) <= 4) {
				   $IRButton = 'presetlast';
					$Count = $StationCurr-$StationNew;
				} else {
				   $IRButton = 'presetnext';
					$Count = 8-$StationCurr+$StationNew;
				}

				IPS_SetInfo ($ControlId, $StationNew);
				IPSLogger_Dbg(__file__, "Switch Yamaha TunerStation from ".$StationCurr." to ".$StationNew." ==> ".$Count."x ".$IRButton);
				for ($idx=1; $idx<=$Count; $idx++) {
					include_once "Entertainment_InterfaceWinLIRC.ips.php";
               WinLIRC_SendData(array(c_Comm_WinLIRC, 'yamahareceiver', $IRButton));
					sleep(0.2);
				}
				return false; // Abort current Processing
			}
		}
		return true;
	}
		/**
		 * @public
		 *
		 * Initialisierung eines IPSComponentShutter_FS20 Objektes
		 *
		 * @param integer $instanceId InstanceId des FS20 Devices
		 */
		public function __construct($instanceId) {
			$this->instanceId = IPSUtil_ObjectIDByPath($instanceId);
			$this->isRunningId  = @IPS_GetObjectIDByIdent('isrunning', $this->instanceId);
			if($this->isRunningId===false) {
				$this->isRunningId = IPS_CreateVariable(0);
				IPS_SetParent($this->isRunningId, $this->instanceId);
				IPS_SetName($this->isRunningId, 'IsRunning');
				IPS_SetIdent($this->isRunningId, 'isrunning');
				IPS_SetInfo($this->isRunningId, "This Variable was created by Script IPSComponentShutter_FS20");
			}
		}
Exemplo n.º 3
0
 public function Create()
 {
     //Never delete this line!
     parent::Create();
     $this->RegisterPropertyString("Username", "");
     $this->RegisterPropertyString("Password", "");
     $this->RegisterPropertyString("APIKey", "");
     $this->RegisterPropertyInteger("Update", 600);
     IPS_SetInfo($this->InstanceID, 'Request an API key at http://api.foobot.io/apidoc/index.html');
     // Create Update Script
     $ID = $this->RegisterScript("FoobotUpdate", "Foobot Update", $this->CreateUpdateScript(), -8);
     IPS_SetScriptTimer($ID, $this->ReadPropertyString('Update'));
     IPS_SetHidden($ID, true);
 }
Exemplo n.º 4
0
 /**
  * constructor
  *
  * @throws Exception if $type is not valid
  * @access public
  */
 public function __construct($parentId, $name, $content, $debug = false)
 {
     $this->parentId = $parentId;
     $this->name = $name;
     $this->content = $content;
     $this->debug = $debug;
     $this->id = @IPS_GetScriptIDByName($this->name, $this->parentId);
     //check if event does already exist
     if ($this->id == false) {
         if ($this->debug) {
             echo "INFO - create IPS script {$name}\n";
         }
         $this->id = IPS_CreateScript(0);
         IPS_SetName($this->id, $this->name);
         IPS_SetParent($this->id, $this->parentId);
         IPS_SetScriptContent($this->id, $this->content);
         IPS_SetInfo($this->id, "this script was created by script " . $_IPS['SELF'] . " which is part of the ips-library (https://github.com/florianprobst/ips-library)");
     }
 }
Exemplo n.º 5
0
 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);
         }
     }
 }
 /**
  * constructor
  *
  * second constructor: create the variable in symcon if it does not exist
  *
  * @param string $name name of the variable
  * @param integer $type IPS datatype
  * @param integer $parent id of the variables parent, this defines where the variable will be created
  * @param mixed $value initially set a variable value
  * @param IPSVariableProfile $profile variable profile for this variable
  * @param boolean $enableLogging enables or disables the ips functionality to log variable changes in a database
  * @param integer $archiveId instance id of the archive control (usually located in IPS\core)
  * @param integer $aggregationType logging aggregation: 0 = gauge, 1 = counter
  * @param boolean $debug enables / disables debug information
  *
  * @throws Exception if the parameter \$profile is not an IPSVariableProfile datatype
  * @access public
  */
 private function __construct2($name, $type, $parent, $profile = NULL, $enableLogging = false, $archiveId = NULL, $aggregationType = 0, $debug = false)
 {
     if (isset($profile) && !$profile instanceof IPSVariableProfile) {
         throw new Exception("Parameter \$profile must be an instance of IPSVariableProfile! \$name of the variable is '{$name}'");
     }
     $this->name = $name;
     $this->type = $type;
     $this->parent = $parent;
     $this->profile = $profile;
     $this->enableLogging = $enableLogging;
     $this->archiveId = $archiveId;
     $this->aggregationType = $aggregationType;
     $this->debug = $debug;
     $this->id = @IPS_GetVariableIDByName($name, $parent);
     if ($this->id == false) {
         if ($this->debug) {
             echo "INFO - create IPS variable {$name}\n";
         }
         $this->id = IPS_CreateVariable($this->type);
         IPS_SetName($this->id, $name);
         IPS_SetParent($this->id, $parent);
         IPS_SetInfo($this->id, "this variable was created by script " . $_IPS['SELF'] . " which is part of the ips-library (https://github.com/florianprobst/ips-library)");
         if (isset($profile)) {
             IPS_SetVariableCustomProfile($this->id, $profile->getName());
         }
         $this->verifyVariableLogging();
     }
 }
 /**
  * constructor
  *
  * @throws Exception if $type is not valid
  * @access public
  */
 public function __construct($parentId, $trigger, $type, $name, $debug = false)
 {
     if (!($type == self::tUPDATE || $type == self::tCHANGE || $type == self::tCAP || $type == self::tFLOOR || $type == self::tVALUE)) {
         throw new Exception("Parameter \$type must be a valid trigger event type, see ip symcon documentation");
     }
     if ($type == self::tCAP || $type == self::tFLOOR || $type == self::tVALUE) {
         throw new Exception("Only TriggerEvents of type UPDATE and CHANGE are implemented yet.");
     }
     $this->parentId = $parentId;
     $this->trigger = $trigger;
     $this->type = $type;
     $this->name = $name;
     $this->debug = $debug;
     $this->id = @IPS_GetEventIDByName($this->name, $this->parentId);
     //check if event does already exist
     if ($this->id == false) {
         if ($this->debug) {
             echo "INFO - create IPS event {$name}\n";
         }
         $this->id = IPS_CreateEvent(0);
         //create trigger event and store id
         IPS_SetName($this->id, $this->name);
         //set event name
         IPS_SetEventTrigger($this->id, $this->type, $this->trigger);
         //configure event trigger
         IPS_SetParent($this->id, $this->parentId);
         //move event to parent (this will be called when trigger occurs)
         IPS_SetInfo($this->id, "this event was created by script " . $_IPS['SELF'] . " which is part of the ips-library (https://github.com/florianprobst/ips-library)");
         $this->activate();
     }
 }
 /**
  * constructor
  *
  * @throws Exception if $type is not valid
  * @access public
  */
 public function __construct($parentId, $name, $cycle, $debug = false)
 {
     $this->parentId = $parentId;
     $this->name = $name;
     $this->cycle = $cycle;
     $this->debug = $debug;
     $this->id = @IPS_GetEventIDByName($this->name, $this->parentId);
     //check if event does already exist
     if ($this->id == false) {
         if ($this->debug) {
             echo "INFO - create IPS event {$name}\n";
         }
         $this->id = IPS_CreateEvent(1);
         //create trigger event and store id
         IPS_SetName($this->id, $this->name);
         //set event name
         IPS_SetParent($this->id, $this->parentId);
         //move event to parent (this will be called when trigger occurs)
         IPS_SetEventCyclic($this->id, 0, 1, 0, 0, 1, $cycle);
         //every $cycle seconds
         IPS_SetInfo($this->id, "this event was created by script " . $_IPS['SELF'] . " which is part of the ips-library (https://github.com/florianprobst/ips-library)");
         $this->activate();
     }
 }
Exemplo n.º 9
0
 public function GenerateMediaObjectEx(string $Text, int $MediaID, string $Format, string $Codec, string $Language)
 {
     if ($MediaID == 0) {
         $MediaID = @IPS_GetObjectIDByIdent('Voice', $this->InstanceID);
     }
     if ($MediaID > 0) {
         if (IPS_MediaExists($MediaID) === false) {
             trigger_error('MediaObject not exists.', E_USER_NOTICE);
         }
         return false;
         if (IPS_GetMedia($MediaID)['MediaType'] != 2) {
             trigger_error('Wrong MediaType', E_USER_NOTICE);
         }
         return false;
     }
     $raw = $this->LoadTTSFile($Text, '', 0, $Format, $Codec, $Language, true);
     if ($raw === false) {
         return false;
     }
     if ($MediaID === false) {
         $MediaID = IPS_CreateMedia(2);
         IPS_SetMediaCached($MediaID, true);
         IPS_SetName($MediaID, 'Voice');
         IPS_SetParent($MediaID, $this->InstanceID);
         IPS_SetIdent($MediaID, 'Voice');
     }
     $Filename = 'media' . DIRECTORY_SEPARATOR . $MediaID . '.' . strtolower($Codec);
     IPS_SetMediaFile($MediaID, $Filename, False);
     IPS_SetMediaContent($MediaID, base64_encode($raw));
     IPS_SetInfo($MediaID, $Text);
     return $MediaID;
 }
Exemplo n.º 10
0
 protected function SetTimerByIdent_InSekunden($ident, $Sekunden)
 {
     $eid = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);
     if ($eid === false) {
         $eid = IPS_CreateEvent(1);
         IPS_SetParent($eid, $this->InstanceID);
         IPS_SetName($eid, $ident);
         IPS_SetIdent($eid, $ident);
         IPS_SetEventScript($eid, 'HMON_Benachrichtigung($_IPS[\'TARGET\'], false, true);');
         IPS_SetInfo($eid, "this timer was created by script #" . $_IPS['SELF']);
     }
     if ($Sekunden === false) {
         IPS_SetEventActive($eid, false);
         return $eid;
     } else {
         IPS_SetEventCyclicTimeFrom($eid, intval(date("H", time() + $Sekunden)), intval(date("i", time() + $Sekunden)), intval(date("s", time() + $Sekunden)));
         IPS_SetEventActive($eid, true);
         return $eid;
     }
 }