コード例 #1
0
	function Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageType=c_MessageType_Action) {
		IPSLogger_Trc(__file__, 'Handle Device Power for "'.$DeviceName.'" '.bool2OnOff($Value));
		$PowerId = get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower, false);
		if ($PowerId!==false) {
		   if (!is_bool($Value)) { 												/*Toggle Power Value*/
      		$Value = !GetValue($PowerId);
				IPSLogger_Dbg(__file__, "Toogle Device Power for '$DeviceName' to ".bool2OnOff($Value));
   		}
			if (GetValue($PowerId) <> $Value) {
				IPSLogger_Inf(__file__, 'Set Device Power for "'.$DeviceName.'" '.bool2OnOff($Value));
				if ($Value) {
					Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower,
																	array(c_Property_CommPowerOn, c_Property_CommPower), $MessageType);
				} else {
					Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower,
																	array(c_Property_CommPowerOff, c_Property_CommPower), $MessageType);
				}
				SetValue($PowerId, $Value);
				Entertainment_Connect($DeviceName, $Value, true);
				Entertainment_SetDeviceControlByDeviceName($DeviceName, c_Control_Muting, false);
		      Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value);
			}
		}
	}
コード例 #2
0
	function Entertainment_SetMuting($Id, $Value, $MessageType=c_MessageType_Action) {
	   $DeviceName = IPS_GetName(IPS_GetParent($Id));
		if (!isDevicePoweredOnByDeviceName($DeviceName)) {
			return;
		}
	   if (!is_bool($Value)) { 												/*Toggle Power Value*/
	      $Value = !GetValue($Id);
		}
		if (GetValue($Id) <> $Value) {
			IPSLogger_Inf(__file__, 'Set Muting "'.bool2OnOff($Value).'" for Device "'.$DeviceName.'"');
			SetValue($Id, $Value);
			if ($Value) {
		  		Entertainment_SendDataByDeviceName($DeviceName, c_Control_Muting,
				  			array(c_Property_CommMuteOn, c_Property_CommMute), $MessageType);
			} else {
		  		Entertainment_SendDataByDeviceName($DeviceName, c_Control_Muting,
				  			array(c_Property_CommMuteOff, c_Property_CommMute), $MessageType);
			}
			Entertainment_SetRoomControlByDeviceControlId($Id, $Value);
		}
	}